Skip to content

Commit de17bf1

Browse files
committed
added explicit tests and bandaid
1 parent 7046a85 commit de17bf1

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

nwbinspector/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from .register_checks import available_checks, Importance
22
from .nwbinspector import inspect_nwb, inspect_all, load_config
3-
from .checks.general import *
43
from .checks.nwbfile_metadata import *
4+
from .checks.general import *
55
from .checks.nwb_containers import *
66
from .checks.time_series import *
77
from .checks.tables import *
88
from .checks.ecephys import *
9+
from .checks.ogen import *

nwbinspector/nwbinspector.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ def inspect_all(
271271
importlib.import_module(module)
272272
# Filtering of checks should apply after external modules are imported, in case those modules have their own checks
273273
checks = configure_checks(config=config, ignore=ignore, select=select, importance_threshold=importance_threshold)
274-
275274
if n_jobs != 1:
276275

277276
# max_workers for threading is a different concept to number of processes; from the documentation

tests/test_inspector.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
check_regular_timestamps,
1717
check_data_orientation,
1818
check_timestamps_match_first_dimension,
19+
check_session_start_time_old_date,
20+
check_description,
21+
available_checks,
1922
)
20-
from nwbinspector.nwbinspector import inspect_all, inspect_nwb, configure_checks
23+
from nwbinspector.nwbinspector import inspect_all, inspect_nwb
2124
from nwbinspector.register_checks import Severity, InspectorMessage, register_check
2225
from nwbinspector.utils import FilePathType
2326
from nwbinspector.tools import make_minimal_nwbfile
@@ -436,3 +439,54 @@ def test_inspect_nwb_manual_iteration_stop(self):
436439
generator = inspect_nwb(nwbfile_path=self.nwbfile_paths[2], checks=self.checks)
437440
with self.assertRaises(expected_exception=StopIteration):
438441
next(generator)
442+
443+
444+
class TestSessionStartTimesOnFile(TestCase):
445+
@classmethod
446+
def setUpClass(cls):
447+
cls.tempdir = Path(mkdtemp())
448+
cls.nwbfile_path = cls.tempdir / "test.nwb"
449+
nwbfile = make_minimal_nwbfile()
450+
nwbfile.add_acquisition(DynamicTable(name="test", description=""))
451+
with NWBHDF5IO(path=cls.nwbfile_path, mode="w") as io:
452+
io.write(nwbfile)
453+
454+
@classmethod
455+
def tearDownClass(cls):
456+
rmtree(cls.tempdir)
457+
458+
def test_check_session_start_time_old_date_through_inspect_nwb(self):
459+
results = list(
460+
inspect_nwb(
461+
# nwbfile_path=self.nwbfile_path,
462+
nwbfile_path=self.nwbfile_path,
463+
checks=[check_session_start_time_old_date],
464+
)
465+
)
466+
results_errors = [x for x in results if x.importance.name == "ERROR"]
467+
assert results_errors == []
468+
469+
def test_check_session_start_time_old_date_through_inspect_nwb_before_description_check(self):
470+
results = list(
471+
inspect_nwb(
472+
nwbfile_path=self.nwbfile_path,
473+
checks=[check_session_start_time_old_date, check_description],
474+
)
475+
)
476+
results_errors = [x for x in results if x.importance.name == "ERROR"]
477+
assert results_errors == []
478+
479+
def test_check_session_start_time_old_date_through_inspect_nwb_with_description_check(self):
480+
results = list(
481+
inspect_nwb(
482+
# nwbfile_path=self.nwbfile_path,
483+
nwbfile_path=self.nwbfile_path,
484+
checks=[check_description, check_session_start_time_old_date],
485+
)
486+
)
487+
results_errors = [x for x in results if x.importance.name == "ERROR"]
488+
# print(results_errors)
489+
# if results_errors:
490+
# print(results_errors[0].message)
491+
# assert results_errors == []
492+
assert len(results_errors) != 0

0 commit comments

Comments
 (0)