From ee0ddd8ea47ef8bcda836442888ad5b0997a890b Mon Sep 17 00:00:00 2001 From: Jan Range <30547301+JR-1991@users.noreply.github.com> Date: Wed, 13 Aug 2025 12:14:35 +0200 Subject: [PATCH 1/5] Update pydataverse dependency to v0.3.4 Bumped the pydataverse package version from 0.3.1 to 0.3.4 in pyproject.toml to ensure compatibility with recent features and bug fixes. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a708295..742af8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ packages = [{ include = "easyDataverse" }] [tool.poetry.dependencies] python = "^3.9" pydantic = "^2.7.1" -pydataverse = "^0.3.1" +pydataverse = "^0.3.4" pyaml = "^24.4.0" xmltodict = "^0.13.0" python-forge = "18.6.0" From f12fd8f6898aa93779a9a6210e1c01ba2910f956 Mon Sep 17 00:00:00 2001 From: Jan Range <30547301+JR-1991@users.noreply.github.com> Date: Thu, 14 Aug 2025 11:47:21 +0200 Subject: [PATCH 2/5] Raise error on double dataset upload attempt Added a check in Dataset.upload to raise a ValueError if the dataset has already been uploaded (p_id is not None). Also added an integration test to verify that attempting to upload the same dataset twice raises the expected error. --- easyDataverse/dataset.py | 6 ++++ tests/integration/test_dataset_creation.py | 37 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/easyDataverse/dataset.py b/easyDataverse/dataset.py index 66a0ff8..9f45add 100644 --- a/easyDataverse/dataset.py +++ b/easyDataverse/dataset.py @@ -301,6 +301,12 @@ def upload( str: The identifier of the uploaded dataset. """ + if self.p_id is not None: + raise ValueError( + "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.", + "If you are sure that you want to upload a new version of the dataset, please set the 'p_id' field to 'None'.", + ) + self._validate_required_fields() self.p_id = upload_to_dataverse( diff --git a/tests/integration/test_dataset_creation.py b/tests/integration/test_dataset_creation.py index 612631d..1caf391 100644 --- a/tests/integration/test_dataset_creation.py +++ b/tests/integration/test_dataset_creation.py @@ -96,6 +96,43 @@ def test_creation_and_upload( "File should be in the sub-directory" ) + @pytest.mark.integration + def test_double_upload_raises_error( + self, + credentials, + ): + # Arrange + base_url, api_token = credentials + dataverse = Dataverse( + server_url=base_url, + api_token=api_token, + ) + + # Act + 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="john@doe.com", + ) + + dataset.add_directory( + dirpath="./tests/fixtures", + dv_dir="some/sub/dir", + ) + + dataset.upload(dataverse_name="root") + + with pytest.raises(ValueError): + dataset.upload(dataverse_name="root") + @pytest.mark.integration def test_creation_and_upload_with_dataset_type( self, From 57e806badabdb8edc854b162b36a9fb9ed1288ac Mon Sep 17 00:00:00 2001 From: Jan Range <30547301+JR-1991@users.noreply.github.com> Date: Thu, 14 Aug 2025 12:52:27 +0200 Subject: [PATCH 3/5] Update easyDataverse/dataset.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- easyDataverse/dataset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easyDataverse/dataset.py b/easyDataverse/dataset.py index 9f45add..61f9eb1 100644 --- a/easyDataverse/dataset.py +++ b/easyDataverse/dataset.py @@ -304,7 +304,8 @@ def upload( if self.p_id is not None: raise ValueError( "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.", - "If you are sure that you want to upload a new version of the dataset, please set the 'p_id' field to 'None'.", + "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.\n" + "If you are sure that you want to upload a new version of the dataset, please set the 'p_id' field to 'None'." ) self._validate_required_fields() From ba21f3911f0bb82ccb80c494968ce38ae59d55ba Mon Sep 17 00:00:00 2001 From: Jan Range <30547301+JR-1991@users.noreply.github.com> Date: Fri, 15 Aug 2025 16:30:59 +0200 Subject: [PATCH 4/5] Update pydataverse dependency to 0.3.5 Bumped the pydataverse package version from 0.3.4 to 0.3.5 in pyproject.toml to ensure compatibility with the latest features and bug fixes. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 742af8b..f95400c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ packages = [{ include = "easyDataverse" }] [tool.poetry.dependencies] python = "^3.9" pydantic = "^2.7.1" -pydataverse = "^0.3.4" +pydataverse = "^0.3.5" pyaml = "^24.4.0" xmltodict = "^0.13.0" python-forge = "18.6.0" From da70917668f4a4e93d5c4117d5df36a05901244e Mon Sep 17 00:00:00 2001 From: Jan Range <30547301+JR-1991@users.noreply.github.com> Date: Wed, 27 Aug 2025 14:24:03 +0200 Subject: [PATCH 5/5] Remove duplicate error message in dataset upload Eliminated a repeated error message when attempting to upload a dataset that has already been uploaded. The message now provides clearer instructions for users. --- easyDataverse/dataset.py | 1 - 1 file changed, 1 deletion(-) diff --git a/easyDataverse/dataset.py b/easyDataverse/dataset.py index 61f9eb1..fbb1c34 100644 --- a/easyDataverse/dataset.py +++ b/easyDataverse/dataset.py @@ -303,7 +303,6 @@ def upload( if self.p_id is not None: raise ValueError( - "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.", "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.\n" "If you are sure that you want to upload a new version of the dataset, please set the 'p_id' field to 'None'." )