def test_start_table_load_fails_if_invalid_module(self): """Test that start_table_load fails if its table is not defined.""" with self.assertLogs(level='ERROR'): bq_load.start_table_load(self.mock_bq_client, self.mock_dataset, self.mock_table_id, schema_type='nonsense_schema')
def test_start_table_load_table_load_called(self): """Test that start_table_load calls load_table_from_uri.""" bq_load.start_table_load(self.mock_dataset, self.mock_table_id, self.schema_type) mock_client = self.mock_bq_utils.client.return_value mock_client.load_table_from_uri.assert_called_with( self.mock_export_uri, self.mock_dataset.table(self.mock_table_id), job_config=mock.ANY)
def test_start_table_load_table_load_called(self): """Test that start_table_load calls load_table_from_uri.""" bq_load.start_table_load(self.mock_bq_client, self.mock_dataset, self.mock_table_id, self.schema_type) self.mock_bq_client.load_table_from_cloud_storage_async.assert_called() self.mock_bq_client.load_table_from_cloud_storage_async.assert_called_with( destination_dataset_ref=self.mock_dataset, destination_table_id=self.mock_table_id, destination_table_schema=[ SchemaField('my_column', 'STRING', 'NULLABLE', None, ()) ], source_uri=self.mock_export_uri)
def test_start_table_load_fails_if_missing_table(self): """Test that start_table_load fails if its table is not defined.""" with self.assertLogs(level='ERROR'): bq_load.start_table_load(self.mock_dataset, 'nonsense_table', self.schema_type)
def test_start_table_load_creates_dataset(self): """Test that start_table_load tries to create a parent dataset.""" bq_load.start_table_load(self.mock_dataset, self.mock_table_id, self.schema_type) self.mock_bq_utils.create_dataset_if_necessary.assert_called_with( self.mock_dataset)