Skip to content

Commit

Permalink
Merge pull request #965 from dandi/test_fixes
Browse files Browse the repository at this point in the history
Removed duplicate, and simplified bids validator tests
  • Loading branch information
yarikoptic committed Apr 21, 2022
2 parents c67a68d + 786c22b commit 2c4dcdd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 56 deletions.
50 changes: 28 additions & 22 deletions dandi/tests/test_bids_validator_xs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import os

BIDS_EXAMPLES_WHITELIST = [
"asl003",
"eeg_cbm",
"hcp_example_bids",
"micr_SEM",
"micr_SEM-dandi",
"micr_SPIM",
"pet001",
"pet003",
"qmri_megre",
"qmri_tb1tfl",
"qmri_vfa",
]
TEST_SCHEMA_PATH = "{module_path}/support/bids/schemadata/1.7.0+012+dandi001"


def test__add_entity():
from dandi.bids_validator_xs import _add_entity
Expand Down Expand Up @@ -289,48 +304,39 @@ def test_write_report(tmp_path):
assert report_text == expected_report_text


def test_bids_datasets(bids_examples, tmp_path):
def test_bids_datasets(bids_examples):
from dandi.bids_validator_xs import validate_bids

whitelist = [
"asl003",
"eeg_cbm",
"hcp_example_bids",
"micr_SEM",
"micr_SEM-dandi",
"micr_SPIM",
"pet001",
"pet003",
"qmri_tb1tfl",
"qmri_vfa",
]
schema_path = "{module_path}/support/bids/schemadata/1.7.0+012+dandi001"

# Validate per dataset, with automatic schema selection:
for i in os.listdir(bids_examples):
if i in whitelist:
if i in BIDS_EXAMPLES_WHITELIST:
result = validate_bids(
os.path.join(bids_examples, i),
)
# Have all files been validated?
assert len(result["path_tracking"]) == 0


def test_bids_datasets_selected_paths(bids_examples, tmp_path):
from dandi.bids_validator_xs import validate_bids

# Create input for file list based validation
selected_dir = os.path.join(bids_examples, whitelist[0])
selected_dir = os.path.join(bids_examples, BIDS_EXAMPLES_WHITELIST[0])
selected_paths = []
for root, dirs, files in os.walk(selected_dir, topdown=False):
for f in files:
selected_path = os.path.join(root, f)
selected_paths.append(selected_path)
# Does terminal debug output work and explicit schema specification work?
result = validate_bids(selected_paths, schema_version=schema_path, debug=True)
# Does default log path specification work?
result = validate_bids(selected_paths, schema_version=schema_path, report_path=True)
# Does explicit schema specification work?
result = validate_bids(selected_paths, schema_version=TEST_SCHEMA_PATH)

# Does terminal debug output work?
result = validate_bids(selected_paths, schema_version=TEST_SCHEMA_PATH, debug=True)

# Does custom log path specification work?
result = validate_bids(
selected_paths,
schema_version=schema_path,
schema_version=TEST_SCHEMA_PATH,
debug=True,
report_path=os.path.join(tmp_path, "test_bids.log"),
)
Expand Down
34 changes: 0 additions & 34 deletions dandi/tests/test_validate.py

This file was deleted.

0 comments on commit 2c4dcdd

Please sign in to comment.