-
Notifications
You must be signed in to change notification settings - Fork 9
Fix multiple compounds update #65
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea630b0
Ignore test-generated files in .gitignore
JR-1991 79c71cf
Use class-level model_fields in DataverseBase
JR-1991 988f3b9
Track attribute changes in generated add functions
JR-1991 b23ec07
Add integration test for dataset update with multiple fields
JR-1991 bae06b7
Bump version to 0.4.5 in pyproject.toml
JR-1991 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
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 |
|---|---|---|
|
|
@@ -63,6 +63,69 @@ def test_dataset_update( | |
| "The updated dataset title does not match the expected title." | ||
| ) | ||
|
|
||
| @pytest.mark.integration | ||
| def test_dataset_update_with_multiple_fields( | ||
| self, | ||
| credentials, | ||
| ): | ||
| # Arrange | ||
| base_url, api_token = credentials | ||
| dataverse = Dataverse( | ||
| server_url=base_url, | ||
| api_token=api_token, | ||
| ) | ||
|
|
||
| # Create a dataset | ||
| dataset = dataverse.create_dataset() | ||
| dataset.citation.title = "My dataset" | ||
| dataset.citation.subject = ["Other"] | ||
| dataset.citation.add_author(name="John Doe") | ||
| dataset.citation.add_ds_description( | ||
| value="This is a description of the dataset", | ||
| date="2024", | ||
| ) | ||
| dataset.citation.add_dataset_contact( | ||
| name="John Doe", | ||
| email="[email protected]", | ||
| ) | ||
|
|
||
| pid = dataset.upload("Root") | ||
|
|
||
| # Act | ||
| # Re-fetch the dataset and add other ID | ||
| dataset = dataverse.load_dataset(pid) | ||
| dataset.citation.add_other_id(agency="DOI", value="10.5072/easy-dataverse") | ||
| dataset.update() | ||
|
|
||
| # Re-fetch the dataset to verify the update | ||
| url = ( | ||
| f"{base_url}/api/datasets/:persistentId/versions/:draft?persistentId={pid}" | ||
| ) | ||
|
|
||
| response = httpx.get( | ||
| url, | ||
| headers={"X-Dataverse-key": api_token}, | ||
| ) | ||
|
|
||
| response.raise_for_status() | ||
| updated_dataset = response.json() | ||
| other_id_field = next( | ||
| filter( | ||
| lambda x: x["typeName"] == "otherId", | ||
| updated_dataset["data"]["metadataBlocks"]["citation"]["fields"], | ||
| ), | ||
| None, | ||
| ) | ||
|
|
||
| # Assert | ||
| assert other_id_field is not None, "Other ID field should be present" | ||
| assert len(other_id_field["value"]) > 0, "Other ID field should have values" | ||
| assert any( | ||
| item["otherIdAgency"]["value"] == "DOI" | ||
| and item["otherIdValue"]["value"] == "10.5072/easy-dataverse" | ||
| for item in other_id_field["value"] | ||
| ), "The DOI other ID should be present in the updated dataset" | ||
|
|
||
| @staticmethod | ||
| def sort_citation(dataset: Dict): | ||
| citation = dataset["datasetVersion"]["metadataBlocks"]["citation"] | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.