def test_upload_data_dataset_not_found(self): test_size = 10 df = make_mixed_dataframe_v2(test_size) with tm.assertRaises(gbq.GenericGBQException): gbq.create_table('pydata_pandas_bq_testing2.new_test', gbq.generate_bq_schema(df), PROJECT_ID)
def test_delete_bq_table(self): table_name = 'new_test8' test_schema = { 'fields': [{ 'name': 'A', 'type': 'FLOAT' }, { 'name': 'B', 'type': 'FLOAT' }, { 'name': 'C', 'type': 'STRING' }, { 'name': 'D', 'type': 'TIMESTAMP' }] } gbq.create_table('pydata_pandas_bq_testing.' + table_name, test_schema, PROJECT_ID) gbq.delete_table('pydata_pandas_bq_testing.' + table_name, PROJECT_ID) self.assertTrue( not gbq.table_exists('pydata_pandas_bq_testing.' + table_name, PROJECT_ID), 'Expected table not to exist')
def test_create_bq_table(self): table_name = 'new_test6' test_schema = {'fields': [{'name': 'A', 'type': 'FLOAT'}, {'name': 'B', 'type': 'FLOAT'}, {'name': 'C', 'type': 'STRING'}, {'name': 'D', 'type': 'TIMESTAMP'}]} gbq.create_table('pydata_pandas_bq_testing.' + table_name, test_schema, PROJECT_ID) self.assertTrue(gbq.table_exists('pydata_pandas_bq_testing.' + table_name, PROJECT_ID), 'Expected table to exist')
def test_upload_data_if_table_exists_fail(self): table_name = 'new_test2' test_size = 10 df = make_mixed_dataframe_v2(test_size) gbq.create_table('pydata_pandas_bq_testing.' + table_name, gbq.generate_bq_schema(df), PROJECT_ID) # Test the default value of if_exists is 'fail' with tm.assertRaises(gbq.TableCreationError): gbq.to_gbq(df, "pydata_pandas_bq_testing." + table_name, PROJECT_ID) # Test the if_exists parameter with value 'fail' with tm.assertRaises(gbq.TableCreationError): gbq.to_gbq(df, "pydata_pandas_bq_testing." + table_name, PROJECT_ID, if_exists='fail')