Skip to content

Commit

Permalink
Finally get tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Feb 9, 2021
1 parent 0983876 commit 034d3e1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dandi/tests/test_dandiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ def downloaded_files():
else:
yield p

dandiset_yaml = download_dir / dandiset_id / dandiset_metadata_file
file_in_version = download_dir / dandiset_id / "subdir" / "file.txt"

download(
f"{local_dandi_api['instance'].api}/dandisets/{dandiset_id}/versions/{version_id}",
download_dir,
)
assert list(downloaded_files()) == [file_in_version]
assert sorted(downloaded_files()) == [dandiset_yaml, file_in_version]
assert file_in_version.read_text() == "This is test text.\n"

(upload_dir / "subdir" / "file.txt").write_text("This is different text.\n")
Expand All @@ -81,7 +82,7 @@ def downloaded_files():
f"{local_dandi_api['instance'].api}/dandisets/{dandiset_id}/versions/{version_id}",
download_dir,
)
assert list(downloaded_files()) == [file_in_version]
assert sorted(downloaded_files()) == [dandiset_yaml, file_in_version]
assert file_in_version.read_text() == "This is test text.\n"

(upload_dir / "subdir" / "file2.txt").write_text("This is more text.\n")
Expand All @@ -99,6 +100,7 @@ def downloaded_files():
download_dir,
)
assert sorted(downloaded_files()) == [
dandiset_yaml,
file_in_version,
file_in_version.with_name("file2.txt"),
]
Expand All @@ -110,7 +112,7 @@ def downloaded_files():
f"{local_dandi_api['instance'].api}/dandisets/{dandiset_id}/versions/{version_id}",
download_dir,
)
assert list(downloaded_files()) == [file_in_version]
assert sorted(downloaded_files()) == [dandiset_yaml, file_in_version]
assert file_in_version.read_text() == "This is test text.\n"

client.delete_asset_bypath(dandiset_id, "draft", "subdir/file.txt")
Expand All @@ -120,13 +122,16 @@ def downloaded_files():
f"{local_dandi_api['instance'].api}/dandisets/{dandiset_id}/versions/draft",
download_dir,
)
assert sorted(downloaded_files()) == [file_in_version.with_name("file2.txt")]
assert sorted(downloaded_files()) == [
dandiset_yaml,
file_in_version.with_name("file2.txt"),
]
assert file_in_version.with_name("file2.txt").read_text() == "This is more text.\n"

rmtree(download_dir / dandiset_id)
download(
f"{local_dandi_api['instance'].api}/dandisets/{dandiset_id}/versions/{version_id}",
download_dir,
)
assert list(downloaded_files()) == [file_in_version]
assert sorted(downloaded_files()) == [dandiset_yaml, file_in_version]
assert file_in_version.read_text() == "This is test text.\n"

0 comments on commit 034d3e1

Please sign in to comment.