Fix empty directoryLabel causing removal of directory label
#43
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.
In #34, it became apparent that CI tests were failing due to mismatched
directoryLabelvalues. This issue is specific to the currentdevelopbranch of Dataverse, which the CI container is using, and will also affect the upcoming 6.8 version. At its core, the upcoming Dataverse version 6.8 introduces a behavior where empty metadata keys passed in the JSON string result in the removal of existing metadata (see IQSS/dataverse#11439). The current implementation of python-dvuploader defaultsdirectoryLabelto an empty string, leading to the removal of thedirectoryLabeland causing a mismatch in the tests.This pull request addresses these issues by modifying the file metadata construction for upload requests and improving error messaging in integration tests. The primary changes include making the
directoryLabelfield conditional, streamlining error handling, and enhancing test assertion messages for clarity.Metadata handling improvements:
_get_json_datafunction indvuploader/nativeupload.pyto only include thedirectoryLabelfield in the metadata dictionary if the file actually has adirectory_labelvalue, ensuring cleaner and more accurate upload requests.Error handling and messaging:
_update_single_metadata, streamlining error management.Test assertion improvements:
test_native_upload_by_handlerintests/integration/test_native_upload.pyto include more descriptive information and pretty-printed JSON, making test failures easier to diagnose.