def test_upload_output(self, mock_s3, mock_utils): mock_utils.return_value = ['/tmp/test/f1', '/tmp/test/k1/f2'] prov = storage.create_provider(self.auth("S3")) storage.upload_output(prov, '/tmp/test') mock_s3.call_count = 2 mock_s3.mock_call()[0] = call('/tmp/test/f1', 'f1') mock_s3.mock_call()[1] = call('/tmp/test/k1/f2', 'k1/f2')
def _get_output_providers(self): """Create output providers based on the environment credentials.""" return [ storage.create_provider( self.stg_auth.get_data_by_stg_id(storage_id), output_path) for storage_id, output_path in storage.get_output_paths() ]
def _get_input_provider(self): """Create an input provider based on the event received.""" event_type = self.parsed_event.get_type() auth_data = self.stg_auth.get_auth_data_by_stg_type(event_type) return create_provider(auth_data)
def test_download_input(self, mock_s3): prov = storage.create_provider(self.auth("S3")) storage.download_input(prov, {}, '/tmp/test') mock_s3.assert_called_once_with({}, '/tmp/test')
def test_create_provider_invalid(self): with self.assertRaises(InvalidStorageProviderError): storage.create_provider(self.auth("ERROR"))
def test_create_provider_s3(self): prov = storage.create_provider(self.auth("S3")) self.assertEqual(prov.get_type(), "S3")
def test_create_provider_onedata(self, onepatch): prov = storage.create_provider(self.auth("ONEDATA")) onepatch.assert_called_once() self.assertEqual(prov.get_type(), "ONEDATA")
def test_create_provider_minio(self): prov = storage.create_provider(self.auth("MINIO")) self.assertEqual(prov.get_type(), "MINIO")
def test_create_provider_local(self): prov = storage.create_provider(()) self.assertEqual(prov.get_type(), "LOCAL")