File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -305,6 +305,12 @@ def upload(
305305 str: The identifier of the uploaded dataset.
306306 """
307307
308+ if self .p_id is not None :
309+ raise ValueError (
310+ "It seems like you are trying to upload a dataset that has already been uploaded. Please use the 'update' method instead.\n "
311+ "If you are sure that you want to upload a new version of the dataset, please set the 'p_id' field to 'None'."
312+ )
313+
308314 self ._validate_required_fields ()
309315
310316 self .p_id = upload_to_dataverse (
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ packages = [{ include = "easyDataverse" }]
1010[tool .poetry .dependencies ]
1111python = " ^3.9"
1212pydantic = " ^2.7.1"
13- pydataverse = " ^0.3.1 "
13+ pydataverse = " ^0.3.5 "
1414pyaml = " ^24.4.0"
1515xmltodict = " ^0.13.0"
1616python-forge = " 18.6.0"
Original file line number Diff line number Diff line change @@ -96,6 +96,43 @@ def test_creation_and_upload(
9696 "File should be in the sub-directory"
9797 )
9898
99+ @pytest .mark .integration
100+ def test_double_upload_raises_error (
101+ self ,
102+ credentials ,
103+ ):
104+ # Arrange
105+ base_url , api_token = credentials
106+ dataverse = Dataverse (
107+ server_url = base_url ,
108+ api_token = api_token ,
109+ )
110+
111+ # Act
112+ dataset = dataverse .create_dataset ()
113+
114+ dataset .citation .title = "My dataset"
115+ dataset .citation .subject = ["Other" ]
116+ dataset .citation .add_author (name = "John Doe" )
117+ dataset .citation .add_ds_description (
118+ value = "This is a description of the dataset" ,
119+ date = "2024" ,
120+ )
121+ dataset .citation .add_dataset_contact (
122+ name = "John Doe" ,
123+ email = "john@doe.com" ,
124+ )
125+
126+ dataset .add_directory (
127+ dirpath = "./tests/fixtures" ,
128+ dv_dir = "some/sub/dir" ,
129+ )
130+
131+ dataset .upload (dataverse_name = "root" )
132+
133+ with pytest .raises (ValueError ):
134+ dataset .upload (dataverse_name = "root" )
135+
99136 @pytest .mark .integration
100137 def test_creation_and_upload_with_dataset_type (
101138 self ,
You can’t perform that action at this time.
0 commit comments