Skip to content

Commit

Permalink
add initial tests for bids-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitj committed Feb 27, 2023
1 parent d9382ab commit ddf8e80
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions snakebids/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_runs_in_correct_mode(
"pybids_db_reset": True,
"snakefile": Path("Snakefile"),
"output_dir": outputdir.resolve(),
"skip_bids_validation": False
}
)
if root == "app" and tail == "":
Expand Down
28 changes: 28 additions & 0 deletions snakebids/tests/test_generate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import more_itertools as itx
import pytest
from bids import BIDSLayout
from bids.exceptions import BIDSValidationError
from hypothesis import HealthCheck, assume, example, given, settings
from hypothesis import strategies as st
from pyfakefs.fake_filesystem import FakeFilesystem
Expand Down Expand Up @@ -998,6 +999,33 @@ def test_when_all_custom_paths_no_layout_indexed(
spy.assert_not_called()


class TestValidate:
@pytest.fixture(autouse=True)
def start(self, tmpdir):
self.bids_dir = "snakebids/tests/data/bids_t1w"
self.tmp_dir = tmpdir.strpath

# Copy test data
shutil.copytree(self.bids_dir, f"{self.tmp_dir}/data")


def test_check_validator(self):
"""Test validator defaults to pybids"""
assert _validate_input_dir(self.bids_dir) == False


# Test for validation failure
def test_pybids_validation_fail(self):
with pytest.raises(BIDSValidationError):
_gen_bids_layout(
bids_dir=f"{self.tmp_dir}/data",
derivatives=False,
pybids_database_dir=None,
pybids_reset_database=False,
validate=True,
)


class TestDB:
@pytest.fixture(autouse=True)
def start(self, tmpdir):
Expand Down

0 comments on commit ddf8e80

Please sign in to comment.