-
Notifications
You must be signed in to change notification settings - Fork 7
DO NOT MERGE - [PERF-286] Update pipeclean to work more generically with an Ed-Fi API #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
stephenfuqua
wants to merge
12
commits into
main
Choose a base branch
from
PERF-286
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
36ac89e
Update locust
stephenfuqua 8b012f6
Remove unused kwargs
stephenfuqua 122ce9a
This has been wrong since at least DS 3.2.0
stephenfuqua 338a68b
Location header handling that works for Meadowlark
stephenfuqua 4050060
Install pytest-describe
stephenfuqua 4d62277
Rewrite using pytest-describe
stephenfuqua 94e671a
Test for building descriptors
stephenfuqua 9821d5f
Type ignore in clients
stephenfuqua d57fa1c
this descriptor is part of the natural key and shouldn't be changeable
stephenfuqua b004ef7
Fixing modeling mistakes that the ODS/API would forgive, but meadowla…
stephenfuqua 0492e5e
Remove unnecessary comment
stephenfuqua 6f50644
Remove unnecessary comment
stephenfuqua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| * text eol=lf | ||
|
|
||
| *.md text | ||
| *.txt text | ||
| *.py text | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| import json | ||
| import logging | ||
| import re | ||
| from typing import Any, Dict | ||
| from typing import Any, Dict, Optional | ||
|
|
||
|
|
||
| import urllib3 | ||
|
|
@@ -118,6 +118,17 @@ def get_item(self, resource_id): | |
| self.log_response(response) | ||
| return json.loads(response.text) | ||
|
|
||
| def _get_resource_id_from_location(self, headers: dict) -> Optional[str]: | ||
| header = "" | ||
| if "Location" in headers: | ||
| header = "Location" | ||
| elif "location" in headers: | ||
| header = "location" | ||
| else: | ||
| return None | ||
|
|
||
| return headers[header].split("/")[-1].strip() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ODS/API and Meadowlark return different cases. Per MDN: "An HTTP header consists of its case-insensitive name". There's probably a better solution available, like lower-casing all headers and looking for "location". This works for now. |
||
|
|
||
| def create(self, unique_id_field=None, name=None, **factory_kwargs): | ||
| # Pass in a `unique_id_field` name (e.g. 'schoolId') to have that | ||
| # attribute returned alongside the resource_id. Useful if you need | ||
|
|
@@ -146,7 +157,8 @@ def create(self, unique_id_field=None, name=None, **factory_kwargs): | |
| return None, None | ||
| return None | ||
| self.log_response(response) | ||
| resource_id = response.headers["Location"].split("/")[-1].strip() | ||
|
|
||
| resource_id = self._get_resource_id_from_location(response.headers) | ||
| if unique_id is not None: | ||
| return resource_id, unique_id | ||
| return resource_id | ||
|
|
@@ -164,8 +176,14 @@ def update(self, resource_id, **update_kwargs): | |
| if self.is_not_expected_result(response, [200, 204]): | ||
| return | ||
| self.log_response(response) | ||
| new_id = response.headers["Location"].split("/")[-1].strip() | ||
| assert new_id == resource_id | ||
|
|
||
| new_id = self._get_resource_id_from_location(response.headers) | ||
|
|
||
| # The ODS/API returns a Location header on PUT requests, but this is not a required feature | ||
| # of an Ed-Fi API. Therefore only apply this test if the location header was found | ||
| if new_id is not None: | ||
| assert new_id == resource_id | ||
|
|
||
| return resource_id | ||
|
|
||
| def delete_item(self, resource_id): | ||
|
|
@@ -246,7 +264,7 @@ def create_using_dependencies(self, dependency_reference=None, **kwargs): | |
| "attributes": resource_attrs, | ||
| } | ||
|
|
||
| def delete_with_dependencies(self, reference, **kwargs): | ||
| def delete_with_dependencies(self, reference): | ||
| """ | ||
| Atomically delete an instance of this resource along with all | ||
| dependencies. The `reference` parameter will contain the necessary | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
popinstead ofget: without the pop, theschoolYearends up directly in the "root" of the course_offering, which is not correct. ODS/API ignores that overposting, but Meadowlark does not.