def has_valid_files(self): """ Check the directory for valid files. Returns: bool, if the directory has valid files, return True. """ ms_dataloader = MSDataLoader(self._summary_dir) return bool(ms_dataloader.filter_valid_files())
def test_filter_event_files(self): """Test filter_event_files function ok.""" file_list = [ 'abc.summary', '123sumary0009abc', 'summary1234', 'aaasummary.5678', 'summary.0012', 'hellosummary.98786', 'mysummary.123abce', 'summay.4567' ] summary_dir = tempfile.mkdtemp() for file in file_list: with open(os.path.join(summary_dir, file), 'w'): pass ms_loader = MSDataLoader(summary_dir) res = ms_loader.filter_valid_files() expected = sorted([ 'aaasummary.5678', 'summary.0012', 'hellosummary.98786', 'mysummary.123abce' ]) shutil.rmtree(summary_dir) assert sorted(res) == expected