def test_files(self): resolwe = MagicMock() data = Data(id=123, resolwe=resolwe) data._get_dir_files = MagicMock( side_effect=[['first_dir/file1.txt'], ['fastq_dir/file2.txt']]) data.output = { 'list': [{'file': "element.gz"}], 'dir_list': [{'dir': "first_dir"}], 'fastq': {'file': "file.fastq.gz"}, 'fastq_archive': {'file': "archive.gz"}, 'fastq_dir': {'dir': "fastq_dir"}, } data.process = Process(resolwe=resolwe, output_schema=[ {'name': 'list', 'label': 'List', 'type': 'list:basic:file:'}, {'name': 'dir_list', 'label': 'Dir_list', 'type': 'list:basic:dir:'}, {'name': 'fastq', 'label': 'Fastq', 'type': 'basic:file:fastq:'}, {'name': 'fastq_archive', 'label': 'Fastq_archive', 'type': 'basic:file:'}, {'name': 'fastq_dir', 'label': 'Fastq_dir', 'type': 'basic:dir:'}, ]) file_list = data.files() self.assertCountEqual(file_list, [ 'element.gz', 'archive.gz', 'file.fastq.gz', 'first_dir/file1.txt', 'fastq_dir/file2.txt' ]) file_list = data.files(file_name='element.gz') self.assertEqual(file_list, ['element.gz']) file_list = data.files(field_name='output.fastq') self.assertEqual(file_list, ['file.fastq.gz']) data.output = { 'list': [{'no_file_field_here': "element.gz"}], } data.process.output_schema = [ {'name': 'list', 'label': 'List', 'type': 'list:basic:file:'}, ] with self.assertRaisesRegex(KeyError, "does not contain 'file' key."): data.files() data = Data(resolwe=MagicMock(), id=None) with self.assertRaisesRegex(ValueError, "must be saved before"): data.files()
def test_files(self): data = Data(id=123, resolwe=MagicMock()) data._get_dir_files = MagicMock( side_effect=[['first_dir/file1.txt'], ['fastq_dir/file2.txt']]) data.output = { 'list': [{'file': "element.gz"}], 'dir_list': [{'dir': "first_dir"}], 'fastq': {'file': "file.fastq.gz"}, 'fastq_archive': {'file': "archive.gz"}, 'fastq_dir': {'dir': "fastq_dir"}, } data.process_output_schema = [ {'name': 'list', 'label': 'List', 'type': 'list:basic:file:'}, {'name': 'dir_list', 'label': 'Dir_list', 'type': 'list:basic:dir:'}, {'name': 'fastq', 'label': 'Fastq', 'type': 'basic:file:fastq:'}, {'name': 'fastq_archive', 'label': 'Fastq_archive', 'type': 'basic:file:'}, {'name': 'fastq_dir', 'label': 'Fastq_dir', 'type': 'basic:dir:'}, ] file_list = data.files() self.assertCountEqual(file_list, [ 'element.gz', 'archive.gz', 'file.fastq.gz', 'first_dir/file1.txt', 'fastq_dir/file2.txt' ]) file_list = data.files(file_name='element.gz') self.assertEqual(file_list, ['element.gz']) file_list = data.files(field_name='output.fastq') self.assertEqual(file_list, ['file.fastq.gz']) data.output = { 'list': [{'no_file_field_here': "element.gz"}], } data.process_output_schema = [ {'name': 'list', 'label': 'List', 'type': 'list:basic:file:'}, ] with self.assertRaisesRegex(KeyError, "does not contain 'file' key."): data.files() data = Data(resolwe=MagicMock(), id=None) with self.assertRaisesRegex(ValueError, "must be saved before"): data.files()
def test_files(self): resolwe = MagicMock() data = Data(id=123, resolwe=resolwe) data._get_dir_files = MagicMock( side_effect=[["first_dir/file1.txt"], ["fastq_dir/file2.txt"]]) data.output = { "list": [{ "file": "element.gz" }], "dir_list": [{ "dir": "first_dir" }], "fastq": { "file": "file.fastq.gz" }, "fastq_archive": { "file": "archive.gz" }, "fastq_dir": { "dir": "fastq_dir" }, } data.process = Process( resolwe=resolwe, output_schema=[ { "name": "list", "label": "List", "type": "list:basic:file:" }, { "name": "dir_list", "label": "Dir_list", "type": "list:basic:dir:" }, { "name": "fastq", "label": "Fastq", "type": "basic:file:fastq:" }, { "name": "fastq_archive", "label": "Fastq_archive", "type": "basic:file:", }, { "name": "fastq_dir", "label": "Fastq_dir", "type": "basic:dir:" }, ], ) file_list = data.files() self.assertCountEqual( file_list, [ "element.gz", "archive.gz", "file.fastq.gz", "first_dir/file1.txt", "fastq_dir/file2.txt", ], ) file_list = data.files(file_name="element.gz") self.assertEqual(file_list, ["element.gz"]) file_list = data.files(field_name="output.fastq") self.assertEqual(file_list, ["file.fastq.gz"]) data.output = { "list": [{ "no_file_field_here": "element.gz" }], } data.process.output_schema = [ { "name": "list", "label": "List", "type": "list:basic:file:" }, ] with self.assertRaisesRegex(KeyError, "does not contain 'file' key."): data.files() data = Data(resolwe=MagicMock(), id=None) with self.assertRaisesRegex(ValueError, "must be saved before"): data.files()