Skip to content

Commit 8d6425a

Browse files
committed
chore: remove unrelated test helper changes from PR 2
1 parent e6dd867 commit 8d6425a

2 files changed

Lines changed: 15 additions & 62 deletions

File tree

packages/google-cloud-bigquery/tests/unit/test__pandas_helpers.py

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
import decimal
1919
import functools
2020
import gc
21-
import importlib.metadata as metadata
2221
import operator
2322
import queue
2423
import time
2524
from typing import Union
2625
from unittest import mock
2726
import warnings
2827

28+
import importlib.metadata as metadata
29+
2930
try:
3031
import pandas
3132
import pandas.api.types
@@ -46,12 +47,11 @@
4647
import pytest
4748

4849
from google import api_core
49-
from google.cloud.bigquery import (
50-
_pyarrow_helpers,
51-
_versions_helpers,
52-
exceptions,
53-
schema,
54-
)
50+
51+
from google.cloud.bigquery import exceptions
52+
from google.cloud.bigquery import _pyarrow_helpers
53+
from google.cloud.bigquery import _versions_helpers
54+
from google.cloud.bigquery import schema
5555
from google.cloud.bigquery._pandas_helpers import determine_requested_streams
5656

5757
pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import()
@@ -1831,7 +1831,8 @@ def test__download_table_bqstorage(
18311831
expected_call_count,
18321832
expected_maxsize,
18331833
):
1834-
from google.cloud.bigquery import dataset, table
1834+
from google.cloud.bigquery import dataset
1835+
from google.cloud.bigquery import table
18351836

18361837
queue_used = None # A reference to the queue used by code under test.
18371838

@@ -1884,11 +1885,11 @@ def test__download_table_bqstorage_shuts_down_workers(
18841885
the child threads are also stopped.
18851886
"""
18861887
pytest.importorskip("google.cloud.bigquery_storage_v1")
1888+
from google.cloud.bigquery import dataset
1889+
from google.cloud.bigquery import table
18871890
import google.cloud.bigquery_storage_v1.reader
18881891
import google.cloud.bigquery_storage_v1.types
18891892

1890-
from google.cloud.bigquery import dataset, table
1891-
18921893
monkeypatch.setattr(
18931894
_versions_helpers.BQ_STORAGE_VERSIONS, "_installed_version", None
18941895
)
@@ -2210,10 +2211,10 @@ def test_determine_requested_streams_invalid_max_stream_count():
22102211
bigquery_storage is None, reason="Requires google-cloud-bigquery-storage"
22112212
)
22122213
def test__download_table_bqstorage_w_timeout_error(module_under_test):
2214+
from google.cloud.bigquery import dataset
2215+
from google.cloud.bigquery import table
22132216
from unittest import mock
22142217

2215-
from google.cloud.bigquery import dataset, table
2216-
22172218
mock_bqstorage_client = mock.create_autospec(
22182219
bigquery_storage.BigQueryReadClient, instance=True
22192220
)
@@ -2247,10 +2248,10 @@ def slow_download_stream(
22472248
bigquery_storage is None, reason="Requires google-cloud-bigquery-storage"
22482249
)
22492250
def test__download_table_bqstorage_w_timeout_success(module_under_test):
2251+
from google.cloud.bigquery import dataset
2252+
from google.cloud.bigquery import table
22502253
from unittest import mock
22512254

2252-
from google.cloud.bigquery import dataset, table
2253-
22542255
mock_bqstorage_client = mock.create_autospec(
22552256
bigquery_storage.BigQueryReadClient, instance=True
22562257
)
@@ -2408,38 +2409,3 @@ def test_download_arrow_bqstorage_passes_timeout_to_create_read_session(
24082409
assert retry_policy is not None
24092410
# Check if deadline is set correctly in the retry policy
24102411
assert retry_policy._deadline == timeout
2411-
2412-
2413-
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
2414-
def test_dataframe_to_bq_schema_w_unused_schema_field(module_under_test):
2415-
with mock.patch.object(module_under_test, "pandas_gbq", None):
2416-
with pytest.raises(
2417-
ValueError, match="bq_schema contains fields not present in dataframe"
2418-
):
2419-
module_under_test.dataframe_to_bq_schema(
2420-
pandas.DataFrame(), (schema.SchemaField("not_in_df", "STRING"),)
2421-
)
2422-
2423-
2424-
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
2425-
@pytest.mark.skipif(isinstance(pyarrow, mock.Mock), reason="Requires `pyarrow`")
2426-
def test_get_schema_by_pyarrow_bignumeric(module_under_test):
2427-
series = pandas.Series([decimal.Decimal("1.12345678901")])
2428-
result = module_under_test._get_schema_by_pyarrow("col", series)
2429-
assert result is not None
2430-
assert result.field_type == "BIGNUMERIC"
2431-
2432-
2433-
@pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
2434-
@pytest.mark.skipif(isinstance(pyarrow, mock.Mock), reason="Requires `pyarrow`")
2435-
def test_get_types_mapper_range_timestamp_mismatch(module_under_test):
2436-
if not hasattr(pandas, "ArrowDtype"):
2437-
return
2438-
range_ts = pandas.ArrowDtype(
2439-
pyarrow.struct(
2440-
[("start", pyarrow.timestamp("us")), ("end", pyarrow.timestamp("us"))]
2441-
)
2442-
)
2443-
mapper = module_under_test.default_types_mapper(range_timestamp_dtype=range_ts)
2444-
unmatched_struct = pyarrow.struct([("other", pyarrow.int64())])
2445-
assert mapper(unmatched_struct) is None

packages/google-cloud-bigquery/tests/unit/test__pyarrow_helpers.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,3 @@ def test_bq_to_arrow_scalars(module_under_test):
4444
def test_arrow_scalar_ids_to_bq(module_under_test):
4545
assert module_under_test.arrow_scalar_ids_to_bq(pyarrow.bool_().id) == "BOOL"
4646
assert module_under_test.arrow_scalar_ids_to_bq("UNKNOWN_TYPE") is None
47-
48-
49-
def test_pyarrow_helpers_when_pyarrow_none(module_under_test):
50-
import importlib
51-
import sys
52-
from unittest import mock
53-
54-
with mock.patch.dict(sys.modules, {"pyarrow": None}):
55-
importlib.reload(module_under_test)
56-
assert module_under_test.pyarrow is None
57-
assert module_under_test.arrow_scalar_ids_to_bq(1) is None
58-
59-
importlib.reload(module_under_test)

0 commit comments

Comments
 (0)