Skip to content

Commit

Permalink
Make dataset IDs unique for snippets / systests.
Browse files Browse the repository at this point in the history
Helps in diagnosing leaks.
  • Loading branch information
tseaver committed Sep 25, 2018
1 parent c7643fa commit c39b194
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions bigquery/docs/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,8 @@ def test_table_insert_rows(client, to_delete):

def test_load_table_from_file(client, to_delete):
"""Upload table data from a CSV file."""
dataset_id = 'table_upload_from_file_dataset_{}'.format(_millis())
table_id = 'table_upload_from_file_table_{}'.format(_millis())
dataset_id = 'load_table_from_file_dataset_{}'.format(_millis())
table_id = 'load_table_from_file_table_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
dataset.location = 'US'
client.create_dataset(dataset)
Expand Down Expand Up @@ -1261,7 +1261,7 @@ def test_load_table_from_file(client, to_delete):


def test_load_table_from_uri_csv(client, to_delete, capsys):
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_csv_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ def test_load_table_from_uri_csv(client, to_delete, capsys):


def test_load_table_from_uri_json(client, to_delete, capsys):
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_json_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
dataset.location = 'US'
client.create_dataset(dataset)
Expand Down Expand Up @@ -1381,7 +1381,7 @@ def test_load_table_from_uri_cmek(client, to_delete):


def test_load_table_from_uri_parquet(client, to_delete, capsys):
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_parquet_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def test_load_table_from_uri_parquet(client, to_delete, capsys):


def test_load_table_from_uri_orc(client, to_delete, capsys):
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_orc_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -1458,7 +1458,7 @@ def test_load_table_from_uri_autodetect(client, to_delete, capsys):
followed by more shared code. Note that only the last format in the
format-specific code section will be tested in this test.
"""
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_auto_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -1524,7 +1524,7 @@ def test_load_table_from_uri_append(client, to_delete, capsys):
followed by more shared code. Note that only the last format in the
format-specific code section will be tested in this test.
"""
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_append_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -1603,7 +1603,7 @@ def test_load_table_from_uri_truncate(client, to_delete, capsys):
followed by more shared code. Note that only the last format in the
format-specific code section will be tested in this test.
"""
dataset_id = 'load_table_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_uri_trunc_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down Expand Up @@ -3051,7 +3051,7 @@ def test_list_rows_as_dataframe(client):
@pytest.mark.skipif(pandas is None, reason='Requires `pandas`')
@pytest.mark.skipif(pyarrow is None, reason='Requires `pyarrow`')
def test_load_table_from_dataframe(client, to_delete):
dataset_id = 'load_table_dataframe_dataset_{}'.format(_millis())
dataset_id = 'load_table_from_dataframe_{}'.format(_millis())
dataset = bigquery.Dataset(client.dataset(dataset_id))
client.create_dataset(dataset)
to_delete.append(dataset)
Expand Down
4 changes: 2 additions & 2 deletions bigquery/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ def _load_table_for_dml(self, rows, dataset_id, table_id):
self._fetch_single_page(table)

def test_query_w_dml(self):
dataset_name = _make_dataset_id('dml_tests')
dataset_name = _make_dataset_id('dml_query')
table_name = 'test_table'
self._load_table_for_dml([('Hello World',)], dataset_name, table_name)
query_template = """UPDATE {}.{}
Expand All @@ -1202,7 +1202,7 @@ def test_query_w_dml(self):
self.assertEqual(query_job.num_dml_affected_rows, 1)

def test_dbapi_w_dml(self):
dataset_name = _make_dataset_id('dml_tests')
dataset_name = _make_dataset_id('dml_dbapi')
table_name = 'test_table'
self._load_table_for_dml([('Hello World',)], dataset_name, table_name)
query_template = """UPDATE {}.{}
Expand Down

0 comments on commit c39b194

Please sign in to comment.