@@ -86,10 +86,39 @@ def add_simple_table(nwbfile: NWBFile):
8686class TestInspector (TestCase ):
8787 maxDiff = None
8888
89- @classmethod
90- def setUpClass (cls ):
91- cls .tempdir = Path (mkdtemp ())
92- cls .checks = [
89+ # @classmethod
90+ # def setUpClass(cls):
91+ # cls.tempdir = Path(mkdtemp())
92+ # cls.checks = [
93+ # check_small_dataset_compression,
94+ # check_regular_timestamps,
95+ # check_data_orientation,
96+ # check_timestamps_match_first_dimension,
97+ # ]
98+ # num_nwbfiles = 3
99+ # nwbfiles = list()
100+ # for j in range(num_nwbfiles):
101+ # nwbfiles.append(make_minimal_nwbfile())
102+ # add_big_dataset_no_compression(nwbfiles[0])
103+ # add_regular_timestamps(nwbfiles[0])
104+ # add_flipped_data_orientation_to_processing(nwbfiles[0])
105+ # add_non_matching_timestamps_dimension(nwbfiles[0])
106+ # add_simple_table(nwbfiles[0])
107+ # add_regular_timestamps(nwbfiles[1])
108+ # # Last file to be left without violations
109+
110+ # cls.nwbfile_paths = [str(cls.tempdir / f"testing{j}.nwb") for j in range(num_nwbfiles)]
111+ # for nwbfile_path, nwbfile in zip(cls.nwbfile_paths, nwbfiles):
112+ # with NWBHDF5IO(path=nwbfile_path, mode="w") as io:
113+ # io.write(nwbfile)
114+
115+ # @classmethod
116+ # def tearDownClass(cls):
117+ # rmtree(cls.tempdir)
118+
119+ def setUp (self ):
120+ self .tempdir = Path (mkdtemp ())
121+ self .checks = [
93122 check_small_dataset_compression ,
94123 check_regular_timestamps ,
95124 check_data_orientation ,
@@ -107,14 +136,13 @@ def setUpClass(cls):
107136 add_regular_timestamps (nwbfiles [1 ])
108137 # Last file to be left without violations
109138
110- cls .nwbfile_paths = [str (cls .tempdir / f"testing{ j } .nwb" ) for j in range (num_nwbfiles )]
111- for nwbfile_path , nwbfile in zip (cls .nwbfile_paths , nwbfiles ):
139+ self .nwbfile_paths = [str (self .tempdir / f"testing{ j } .nwb" ) for j in range (num_nwbfiles )]
140+ for nwbfile_path , nwbfile in zip (self .nwbfile_paths , nwbfiles ):
112141 with NWBHDF5IO (path = nwbfile_path , mode = "w" ) as io :
113142 io .write (nwbfile )
114143
115- @classmethod
116- def tearDownClass (cls ):
117- rmtree (cls .tempdir )
144+ def tearDown (self ):
145+ rmtree (self .tempdir )
118146
119147 def assertFileExists (self , path : FilePathType ):
120148 path = Path (path )
@@ -424,32 +452,32 @@ def test_command_line_on_directory_matches_file(self):
424452 skip_first_newlines = True ,
425453 )
426454
427- # def test_iterable_check_function(self):
428- # @register_check(importance=Importance.BEST_PRACTICE_VIOLATION, neurodata_type=DynamicTable)
429- # def iterable_check_function(table: DynamicTable):
430- # for col in table.columns:
431- # yield InspectorMessage(message=f"Column: {col.name}")
432-
433- # test_results = list(inspect_nwb(nwbfile_path=self.nwbfile_paths[0], select=["iterable_check_function"]))
434- # true_results = [
435- # InspectorMessage(
436- # message="Column: start_time",
437- # importance=Importance.BEST_PRACTICE_VIOLATION,
438- # check_function_name="iterable_check_function",
439- # object_type="TimeIntervals",
440- # object_name="test_table",
441- # file_path=self.nwbfile_paths[0],
442- # ),
443- # InspectorMessage(
444- # message="Column: stop_time",
445- # importance=Importance.BEST_PRACTICE_VIOLATION,
446- # check_function_name="iterable_check_function",
447- # object_type="TimeIntervals",
448- # object_name="test_table",
449- # file_path=self.nwbfile_paths[0],
450- # ),
451- # ]
452- # self.assertCountEqual(first=test_results, second=true_results)
455+ def test_iterable_check_function (self ):
456+ @register_check (importance = Importance .BEST_PRACTICE_VIOLATION , neurodata_type = DynamicTable )
457+ def iterable_check_function (table : DynamicTable ):
458+ for col in table .columns :
459+ yield InspectorMessage (message = f"Column: { col .name } " )
460+
461+ test_results = list (inspect_nwb (nwbfile_path = self .nwbfile_paths [0 ], select = ["iterable_check_function" ]))
462+ true_results = [
463+ InspectorMessage (
464+ message = "Column: start_time" ,
465+ importance = Importance .BEST_PRACTICE_VIOLATION ,
466+ check_function_name = "iterable_check_function" ,
467+ object_type = "TimeIntervals" ,
468+ object_name = "test_table" ,
469+ file_path = self .nwbfile_paths [0 ],
470+ ),
471+ InspectorMessage (
472+ message = "Column: stop_time" ,
473+ importance = Importance .BEST_PRACTICE_VIOLATION ,
474+ check_function_name = "iterable_check_function" ,
475+ object_type = "TimeIntervals" ,
476+ object_name = "test_table" ,
477+ file_path = self .nwbfile_paths [0 ],
478+ ),
479+ ]
480+ self .assertCountEqual (first = test_results , second = true_results )
453481
454482 def test_inspect_nwb_manual_iteration (self ):
455483 generator = inspect_nwb (nwbfile_path = self .nwbfile_paths [0 ], checks = self .checks )
0 commit comments