Skip to content

Commit

Permalink
Merge pull request #319 from mih/test-helper
Browse files Browse the repository at this point in the history
test(`pydataverse`): accomodate newer pyDataverse versions (0.3.2+)
  • Loading branch information
mih authored Jul 19, 2024
2 parents 8a55062 + be429bf commit 98ef1b0
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit 98ef1b0

Please sign in to comment.