Skip to content

Commit 9ad752c

Browse files
authored
Merge pull request #43 from gdcc/fix-ci
Fix empty `directoryLabel` causing removal of directory label
2 parents 6209ff2 + 8c643c3 commit 9ad752c

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

dvuploader/nativeupload.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,19 @@ def _get_json_data(file: File) -> Dict:
301301
Returns:
302302
Dict: Dictionary containing file metadata for the upload request.
303303
"""
304-
return {
304+
305+
metadata = {
305306
"description": file.description,
306-
"directoryLabel": file.directory_label,
307307
"categories": file.categories,
308308
"restrict": file.restrict,
309309
"forceReplace": True,
310310
}
311311

312+
if file.directory_label:
313+
metadata["directoryLabel"] = file.directory_label
314+
315+
return metadata
316+
312317

313318
async def _update_metadata(
314319
session: httpx.AsyncClient,
@@ -414,7 +419,6 @@ async def _update_single_metadata(
414419
if response.status_code == 200:
415420
return
416421
else:
417-
print(response.json())
418422
await asyncio.sleep(1.0)
419423

420424
raise ValueError(f"Failed to update metadata for file {file.file_name}.")

tests/integration/test_native_upload.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ def test_native_upload_by_handler(
212212
file = next(file for file in files if file["label"] == ex_f)
213213

214214
assert file["label"] == ex_f, (
215-
f"File label does not match for file {json.dumps(file)}"
215+
f"File label {ex_f} does not match for file {json.dumps(file, indent=2)}"
216216
)
217217

218218
assert file.get("directoryLabel", "") == ex_dir, (
219-
f"Directory label does not match for file {json.dumps(file)}"
219+
f"Directory label '{ex_dir}' of expected file '{ex_f}' does not match for file {json.dumps(file, indent=2)}"
220220
)
221221

222222
assert file["description"] == "This is a test", (

tests/unit/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_return_files_list(self, httpx_mock):
168168
def test_raise_http_error(self):
169169
# Call the function under test and assert that it raises an HTTPError
170170
with pytest.raises(httpx.HTTPStatusError):
171-
retrieve_dataset_files("http://example.com", "12345", "token")
171+
retrieve_dataset_files("http://demo.dataverse.org", "12345", "token")
172172

173173

174174
class TestSetupPbar:

0 commit comments

Comments
 (0)