Skip to content

Commit

Permalink
Minor test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Aug 20, 2021
1 parent 3070ae3 commit b43daf6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions dask_bigquery/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ def df():
@pytest.fixture
def dataset(df):
"Push some data to BigQuery using pandas gbq"
dataset_id = uuid.uuid4().hex
project_id = "dask-bigquery"
dataset_id = uuid.uuid4().hex
table_id = "table_test"
# push data to gbq
pd.DataFrame.to_gbq(
df,
destination_table=f"{dataset_id}.table_test",
destination_table=f"{dataset_id}.{table_id}",
project_id=project_id,
chunksize=5,
if_exists="append",
)
yield f"{project_id}.{dataset_id}.table_test"
yield (project_id, dataset_id, table_id)

with bigquery.Client() as bq_client:
bq_client.delete_dataset(
Expand All @@ -53,14 +54,11 @@ def dataset(df):
# test simple read
def test_read_gbq(df, dataset, client):
"""Test simple read of data pushed to BigQuery using pandas-gbq"""
project_id, dataset_id, table_id = dataset.split(".")

project_id, dataset_id, table_id = dataset
ddf = read_gbq(project_id=project_id, dataset_id=dataset_id, table_id=table_id)

assert ddf.columns.tolist() == ["name", "number", "idx"]
assert len(ddf) == 10
assert list(ddf.columns) == ["name", "number", "idx"]
assert ddf.npartitions == 2

assert assert_eq(ddf.set_index("idx"), df.set_index("idx"))


Expand Down

0 comments on commit b43daf6

Please sign in to comment.