Skip to content

Commit

Permalink
Error testing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChymera committed Jul 28, 2022
1 parent 10d20f5 commit 420e286
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
9 changes: 9 additions & 0 deletions dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ def bids_dandiset(new_dandiset: SampleDandiset, bids_examples: str) -> SampleDan
return new_dandiset


@pytest.fixture()
def bids_dandiset_invalid(new_dandiset: SampleDandiset, bids_examples: str) -> SampleDandiset:
copytree(
os.path.join(bids_examples, "invalid_pet001"),
str(new_dandiset.dspath) + "/",
)
return new_dandiset


@pytest.fixture()
def video_files(tmp_path):
video_paths = []
Expand Down
21 changes: 15 additions & 6 deletions dandi/tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,20 @@ def test_upload_sync_folder(
text_dandiset.dandiset.get_asset_by_path("subdir2/banana.txt")


def test_upload_bids(mocker: MockerFixture, bids_dandiset: SampleDandiset) -> None:
def test_upload_bids_invalid(
mocker: MockerFixture, bids_dandiset_invalid: SampleDandiset
) -> None:
iter_upload_spy = mocker.spy(LocalFileAsset, "iter_upload")
bids_dandiset.upload(existing="forced")
bids_dandiset_invalid.upload(existing="forced")
# Check whether upload failed
iter_upload_spy.assert_not_called()


def test_upload_bids_validation_ignore(
mocker: MockerFixture, bids_dandiset: SampleDandiset
) -> None:
iter_upload_spy = mocker.spy(LocalFileAsset, "iter_upload")
bids_dandiset.upload(existing="forced", validation="ignore")
# Check whether upload was run
iter_upload_spy.assert_called()
# Check existence of assets:
Expand All @@ -196,11 +207,9 @@ def test_upload_bids(mocker: MockerFixture, bids_dandiset: SampleDandiset) -> No
dandiset.get_asset_by_path("sub-Sub1/anat/sub-Sub1_T1w.nii.gz")


def test_upload_bids_validation_ignore(
mocker: MockerFixture, bids_dandiset: SampleDandiset
) -> None:
def test_upload_bids(mocker: MockerFixture, bids_dandiset: SampleDandiset) -> None:
iter_upload_spy = mocker.spy(LocalFileAsset, "iter_upload")
bids_dandiset.upload(existing="forced", validation="ignore")
bids_dandiset.upload(existing="forced")
# Check whether upload was run
iter_upload_spy.assert_called()
# Check existence of assets:
Expand Down

0 comments on commit 420e286

Please sign in to comment.