def test_data_type_tuple(self, collection_mock, data_mock): collection_mock.configure_mock(data=[1, 2], resolwe=MagicMock()) data_mock.side_effect = [DATA1, DATA2] BaseCollection.download(collection_mock, data_type=('data:expression:', 'output.exp')) flist = [u'2/output.exp'] collection_mock.resolwe.download_files.assert_called_once_with(flist, None)
def test_data_type_short(self, collection_mock, data_mock): collection_mock.configure_mock(data=[1, 2], resolwe=MagicMock()) data_mock.side_effect = [DATA1, DATA2] BaseCollection.download(collection_mock, data_type='fastq') flist = [u'1/reads.fq', u'1/arch.gz'] collection_mock.resolwe.download_files.assert_called_once_with(flist, None)
def test_field_name(self, collection_mock): collection_mock.configure_mock(data=[DATA0, DATA2], resolwe=MagicMock()) BaseCollection.download(collection_mock, field_name='output.exp') flist = ['2/outfile.exp'] collection_mock.resolwe._download_files.assert_called_once_with(flist, None) # Check if ok to also provide ``output_field`` that does not start with 'output' collection_mock.reset_mock() collection_mock.configure_mock(data=[DATA1, DATA0], resolwe=MagicMock()) BaseCollection.download(collection_mock, field_name='fastq') flist = ['1/reads.fq', '1/arch.gz'] collection_mock.resolwe._download_files.assert_called_once_with(flist, None)
def test_field_name(self, collection_mock): collection_mock.configure_mock(data=[DATA0, DATA2], resolwe=MagicMock()) BaseCollection.download(collection_mock, field_name="output.exp") flist = ["2/outfile.exp"] collection_mock.resolwe._download_files.assert_called_once_with( flist, None) # Check if ``output_field`` does not start with 'output' collection_mock.reset_mock() collection_mock.configure_mock(data=[DATA1, DATA0], resolwe=MagicMock()) BaseCollection.download(collection_mock, field_name="fastq") flist = ["1/reads.fq", "1/arch.gz"] collection_mock.resolwe._download_files.assert_called_once_with( flist, None)
def test_data_types(self, collection_mock): get_mock = MagicMock(**{'get.return_value': DATA_SAMPLE[0]}) api_mock = MagicMock(**{'data.return_value': get_mock}) collection_mock.configure_mock(data=[1, 2], resolwe=MagicMock(api=api_mock)) types = BaseCollection.data_types(collection_mock) self.assertEqual(types, [u'data:reads:fastq:single:'])
def test_data_types(self, collection_mock): payload = { 'id': 123, 'process_type': 'data:reads:fastq:single:', # ... } get_mock = MagicMock(**{'get.return_value': payload}) api_mock = MagicMock(**{'data.return_value': get_mock}) collection_mock.configure_mock(data=[1, 2], resolwe=MagicMock(api=api_mock)) types = BaseCollection.data_types(collection_mock) self.assertEqual(types, ['data:reads:fastq:single:'])
def test_bad_field_name(self, collection_mock): message = "Invalid argument value `field_name`." with self.assertRaisesRegex(ValueError, message): BaseCollection.download(collection_mock, field_name=123)
def test_files(self, collection_mock): collection_mock.configure_mock(data=[DATA1, DATA2], resolwe=" ") flist = BaseCollection.files(collection_mock) self.assertEqual(set(flist), set(['arch.gz', 'reads.fq', 'outfile.exp']))
def test_bad_file_type(self, collection_mock): message = "Invalid argument value `file_type`." with six.assertRaisesRegex(self, ValueError, message): BaseCollection.download(collection_mock, file_type=123)
def test_print_annotation(self, collection_mock): with self.assertRaises(NotImplementedError): BaseCollection.print_annotation(collection_mock)
def test_bad_data_type(self, collection_mock, data_mock): message = "Invalid argument value data_type." with six.assertRaisesRegex(self, ValueError, message): BaseCollection.download(collection_mock, data_type=123)
def test_data_types(self, collection_mock): api_mock = MagicMock(**{'data.return_value': MagicMock(**{'get.return_value': DATA_SAMPLE[0]})}) collection_mock.configure_mock(data=[1, 2], resolwe=MagicMock(api=api_mock)) types = BaseCollection.data_types(collection_mock) self.assertEqual(types, [u'data:reads:fastq:single:'])
def test_init(self, collection_mock): collection_mock.configure_mock(endpoint="fake_endpoint") BaseCollection.__init__(collection_mock, id=1, resolwe=MagicMock())