Skip to content

Commit

Permalink
Merge pull request #415 from dandi/gh-411
Browse files Browse the repository at this point in the history
Add test of upload of large file to new API
  • Loading branch information
yarikoptic committed Feb 22, 2021
2 parents ec58079 + d6035d3 commit 2dfe376
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dandi/tests/test_dandiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,18 @@ def test_get_asset_include_metadata(local_dandi_api, simple1_nwb, tmp_path):
)
assert asset is not None
assert asset["metadata"] == {"path": "testing/simple1.nwb", "foo": "bar"}


def test_large_upload(local_dandi_api, tmp_path):
client = DandiAPIClient(
api_url=local_dandi_api["instance"].api, token=local_dandi_api["api_key"]
)
asset_file = tmp_path / "asset.dat"
meg = bytes(random.choices(range(256), k=1 << 20))
with asset_file.open("wb") as fp:
for _ in range(100):
fp.write(meg)
with client.session():
r = client.create_dandiset(name="Large Upload Test", metadata={})
dandiset_id = r["identifier"]
client.upload(dandiset_id, "draft", {"path": "testing/asset.dat"}, asset_file)

0 comments on commit 2dfe376

Please sign in to comment.