Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(pydataverse): accomodate newer pyDataverse versions (0.3.2+) #319

Merged
merged 1 commit into from
Jul 19, 2024
Merged
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
13 changes: 10 additions & 3 deletions datalad_dataverse/tests/test_pydataverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,21 @@ def test_file_handling(
def check_download(api, fileid, dsid, fpath, src_md5):
# TODO there is no standalone implementation of the following
# reimplementing DataverseRemote._download_file
response = api.get_datafile(fileid)

# recent pydataverse requires saying `is_pid=False` for a file-id
response = api.get_datafile(fileid, is_pid=False)
# TODO this could also just be a download via HttpUrlOperations
# avoiding any custom code
assert response.status_code == 200
with fpath.open("wb") as f:
# use a stupdly small chunksize to actual get chunking on
# accommodate old and newer pydataverse version
try:
it = response.iter_content
except AttributeError:
it = response.iter_bytes
# use a stupdily small chunksize to actual get chunking on
# our tiny test file
for chunk in response.iter_content(chunk_size=1):
for chunk in it(chunk_size=1):
f.write(chunk)

# confirm identity
Expand Down
Loading