Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dvuploader/nativeupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,19 @@ def _get_json_data(file: File) -> Dict:
Returns:
Dict: Dictionary containing file metadata for the upload request.
"""
return {

metadata = {
"description": file.description,
"directoryLabel": file.directory_label,
"categories": file.categories,
"restrict": file.restrict,
"forceReplace": True,
}

if file.directory_label:
metadata["directoryLabel"] = file.directory_label

return metadata


async def _update_metadata(
session: httpx.AsyncClient,
Expand Down Expand Up @@ -414,7 +419,6 @@ async def _update_single_metadata(
if response.status_code == 200:
return
else:
print(response.json())
await asyncio.sleep(1.0)

raise ValueError(f"Failed to update metadata for file {file.file_name}.")
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_native_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ def test_native_upload_by_handler(
file = next(file for file in files if file["label"] == ex_f)

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

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

assert file["description"] == "This is a test", (
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_return_files_list(self, httpx_mock):
def test_raise_http_error(self):
# Call the function under test and assert that it raises an HTTPError
with pytest.raises(httpx.HTTPStatusError):
retrieve_dataset_files("http://example.com", "12345", "token")
retrieve_dataset_files("http://demo.dataverse.org", "12345", "token")


class TestSetupPbar:
Expand Down