From 47854a272aef63af2973a69d591ca0722fa95d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Pawlu=C5=9B?= Date: Wed, 12 Jun 2024 22:48:00 +0200 Subject: [PATCH] update --- src/pyarrow/bigquery/write/__init__.py | 2 -- tests/integration/test_upload.py | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pyarrow/bigquery/write/__init__.py b/src/pyarrow/bigquery/write/__init__.py index 6a370b6..124c984 100644 --- a/src/pyarrow/bigquery/write/__init__.py +++ b/src/pyarrow/bigquery/write/__init__.py @@ -44,8 +44,6 @@ def _bq_create_table(*, project, location, schema, expire, overwrite): client.create_table(table) - print(client.get_table(location)) - if expire: table.expires = datetime.datetime.now() + datetime.timedelta(seconds=expire) client.update_table(table, ["expires"]) diff --git a/tests/integration/test_upload.py b/tests/integration/test_upload.py index 8cb8251..844dc63 100644 --- a/tests/integration/test_upload.py +++ b/tests/integration/test_upload.py @@ -5,14 +5,17 @@ import pyarrow as pa import pyarrow.bigquery as bq -print(os.environ) PROJECT = os.environ['GCP_PROJECT'] -LOCATION = f"{PROJECT}.test.{uuid.uuid4()}" -@pytest.fixture(autouse=True) -def _remove_table(): +@pytest.fixture(scope="function") +def LOCATION(): + return f"{PROJECT}.test.{uuid.uuid4()}" + + +@pytest.fixture(autouse=True, scope='function') +def _remove_table(LOCATION): from google.cloud import bigquery bigquery.Client(project="xando-1-main").delete_table(LOCATION, not_found_ok=True) @@ -20,7 +23,7 @@ def _remove_table(): bigquery.Client(project="xando-1-main").delete_table(LOCATION, not_found_ok=True) -def test_simple(): +def test_simple(LOCATION): table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"]) bq.write_table(table, LOCATION, table_create=True) @@ -31,7 +34,7 @@ def test_simple(): assert table_back.sort_by("test").equals(table.sort_by("test")) -def test_reader_query(): +def test_reader_query(LOCATION): table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"]) bq.write_table(table, LOCATION, table_create=True) @@ -47,7 +50,7 @@ def test_reader_query(): assert table_back2.sort_by("test").equals(table.sort_by("test")) -def test_context(): +def test_context(LOCATION): table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"]) with bq.writer(table.schema, LOCATION, table_create=True) as w: @@ -59,7 +62,7 @@ def test_context(): assert table_back.sort_by("test").equals(table.sort_by("test")) -def test_complex(): +def test_complex(LOCATION): _1d_int = pa.array([1, 2]) _2d_int = pa.array([[1, 2, 3], [4, 5, 6]]) _3d_int = pa.array(