def test_DeleteTable(self): service = self.service() table = "table.to_delete" job = DeleteTable(service) success = job.run(table) service.tables.delete.assert_called_with(**_table(PROJECT_ID, table)) self.assertTrue(job.is_complete) self.assertTrue(success)
def test_PersistQueryToTable(self): service = self.service() query = "SELECT * FROM ds.table LIMIT 100" table = "ds.export_table" PersistQueryToTable(service).run(query, table) body = service.jobs.insert.call_args_list[0][1]['body']['configuration']['query'] expected = _table(PROJECT_ID, table) service.tables.delete.assert_called_once_with(**expected) self.assertEqual(expected, body['destinationTable']) self.assertEqual(query, body['query'])
def test_ExportTableToCSV(self): service = self.service() source = "source.table" destination = "gs://some-path/files.gz" ExportTableToCSV(service).run(source, destination) extract = service.mock_calls[0][2]['body']['configuration']['extract'] check1 = extract['sourceTable'] check2 = extract['destinationUris'] self.assertEqual(service.mock_calls[0][0], "jobs.insert") self.assertEqual(check1, _table(PROJECT_ID, source)) self.assertIn(destination, check2)