Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updates a number of optional dependencies #1864

Merged
merged 42 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5b3e7db
replaces unittest.skipif
chalmerlowe Mar 20, 2024
ad84c43
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 20, 2024
25e28f8
adds a test for bqstorage_client == None
chalmerlowe Mar 21, 2024
6e6d8a1
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
fde7286
fix lint via removal of metadata imports
chalmerlowe Mar 21, 2024
502c430
added pragma
chalmerlowe Mar 21, 2024
a6d0669
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 21, 2024
b5c194b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
c4a9222
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 21, 2024
3ea3304
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 21, 2024
e21c9fe
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 21, 2024
8b47e07
updates unittest to pytest conversion in sys/test_client.py
chalmerlowe Mar 25, 2024
a27d2bd
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 25, 2024
7150c06
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
5c4ede6
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 25, 2024
16fc3ca
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
18219ef
Merge branch 'fix-simplify-dependencies' of https://github.com/google…
gcf-owl-bot[bot] Mar 25, 2024
d030541
unittest to pytest conversion unit/conftest.py
chalmerlowe Mar 25, 2024
acf3abc
updates unittest to pytest conversion test_dbapi__helpers.py
chalmerlowe Mar 25, 2024
34ee2d6
updates unittest to pytest conversion test_dbapi_connection.py
chalmerlowe Mar 25, 2024
7e78927
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 25, 2024
30c1631
unittest to pytest conversion test_dbapi_cursor.py
chalmerlowe Mar 25, 2024
af02cb8
more changes to test_dbapi_connection.py
chalmerlowe Mar 25, 2024
ba8f146
linting, some error fixes re: pyarrow
chalmerlowe Mar 25, 2024
1ed7aad
more updates
chalmerlowe Mar 25, 2024
82f44b0
linting fixes
chalmerlowe Mar 25, 2024
594c3de
updates to some tqdm tests
chalmerlowe Mar 25, 2024
0ae5e1a
Update tests/unit/test_table.py
chalmerlowe Mar 25, 2024
cac8e8f
updates syntax error
chalmerlowe Mar 25, 2024
5a93b0b
revised version checks for pandas using pytest.skip()
chalmerlowe Mar 26, 2024
ed6bf2b
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 26, 2024
8edbf43
revise title of import; should clean up coverage
chalmerlowe Mar 27, 2024
1eead87
last cleanup on missing coverage
chalmerlowe Mar 27, 2024
ccd6bc4
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 27, 2024
49f6724
Update tests/system/test_client.py
chalmerlowe Mar 27, 2024
2a53adf
Update tests/system/test_client.py
chalmerlowe Mar 27, 2024
ba4750f
Update tests/unit/test_client.py
chalmerlowe Mar 27, 2024
3634ab1
Update tests/unit/conftest.py
chalmerlowe Mar 27, 2024
5617542
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 27, 2024
423b9f6
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Mar 27, 2024
0415084
removed errant @fixture flag
chalmerlowe Mar 27, 2024
122f156
Merge branch 'main' into fix-simplify-dependencies
chalmerlowe Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
revise title of import; should clean up coverage
  • Loading branch information
chalmerlowe committed Mar 27, 2024
commit 8edbf4379f1658b0a1b4ec86ca97da8fffc06626
6 changes: 3 additions & 3 deletions tests/system/test_client.py
Expand Up @@ -1791,7 +1791,7 @@ def test_dbapi_fetchall_from_script(self):
self.assertEqual(row_tuples, [(5, "foo"), (6, "bar"), (7, "baz")])

def test_dbapi_fetch_w_bqstorage_client_large_result_set(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pyarrow")
from google.cloud import bigquery_storage

Expand Down Expand Up @@ -1853,7 +1853,7 @@ def test_dbapi_dry_run_query(self):
self.assertEqual(list(rows), [])

def test_dbapi_connection_does_not_leak_sockets(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
current_process = psutil.Process()
conn_count_start = len(current_process.connections())

Expand Down Expand Up @@ -2399,7 +2399,7 @@ def test_create_table_rows_fetch_nested_schema(self):
self.assertEqual(found[8], decimal.Decimal(expected["FavoriteNumber"]))

def test_nested_table_to_arrow(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pyarrow = pytest.importorskip("pyarrow")
pyarrow.types = pytest.importorskip("pyarrow.types")
from google.cloud import bigquery_storage
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_client.py
Expand Up @@ -778,7 +778,7 @@ def test_get_dataset(self):
self.assertEqual(dataset.dataset_id, self.DS_ID)

def test_ensure_bqstorage_client_creating_new_instance(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud import bigquery_storage

mock_client = mock.create_autospec(bigquery_storage.BigQueryReadClient)
Expand Down Expand Up @@ -827,7 +827,7 @@ def fail_bqstorage_import(name, globals, locals, fromlist, level):
assert matching_warnings, "Missing dependency warning not raised."

def test_ensure_bqstorage_client_obsolete_dependency(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
creds = _make_credentials()
client = self._make_one(project=self.PROJECT, credentials=creds)

Expand All @@ -845,7 +845,7 @@ def test_ensure_bqstorage_client_obsolete_dependency(self):
assert matching_warnings, "Obsolete dependency warning not raised."

def test_ensure_bqstorage_client_existing_client_check_passes(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
creds = _make_credentials()
client = self._make_one(project=self.PROJECT, credentials=creds)
mock_storage_client = mock.sentinel.mock_storage_client
Expand All @@ -872,7 +872,7 @@ def test_ensure_bqstorage_client_is_none(self):
)

def test_ensure_bqstorage_client_existing_client_check_fails(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
creds = _make_credentials()
client = self._make_one(project=self.PROJECT, credentials=creds)
mock_storage_client = mock.sentinel.mock_storage_client
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_dbapi_connection.py
Expand Up @@ -56,7 +56,7 @@ def test_ctor_wo_bqstorage_client(self):
self.assertIs(connection._bqstorage_client, None)

def test_ctor_w_bqstorage_client(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery.dbapi import Connection

mock_client = self._mock_client()
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_connect_wo_client(self, mock_client):
self.assertIsNotNone(connection._bqstorage_client)

def test_connect_w_client(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery.dbapi import connect
from google.cloud.bigquery.dbapi import Connection

Expand All @@ -102,7 +102,7 @@ def test_connect_w_client(self):
self.assertIs(connection._bqstorage_client, mock_bqstorage_client)

def test_connect_w_both_clients(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery.dbapi import connect
from google.cloud.bigquery.dbapi import Connection

Expand Down Expand Up @@ -136,7 +136,7 @@ def test_raises_error_if_closed(self):
getattr(connection, method)()

def test_close_closes_all_created_bigquery_clients(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
client = self._mock_client()
bqstorage_client = self._mock_bqstorage_client()

Expand All @@ -159,7 +159,7 @@ def test_close_closes_all_created_bigquery_clients(self):
self.assertTrue(bqstorage_client._transport.grpc_channel.close.called)

def test_close_does_not_close_bigquery_clients_passed_to_it(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
client = self._mock_client()
bqstorage_client = self._mock_bqstorage_client()
connection = self._make_one(client=client, bqstorage_client=bqstorage_client)
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_dbapi_cursor.py
Expand Up @@ -313,7 +313,7 @@ def test_fetchall_w_row(self):
self.assertEqual(rows[0], (1,))

def test_fetchall_w_bqstorage_client_fetch_success(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pyarrow")
from google.cloud.bigquery import dbapi

Expand Down Expand Up @@ -371,7 +371,7 @@ def test_fetchall_w_bqstorage_client_fetch_success(self):
self.assertEqual(sorted_row_data, expected_row_data)

def test_fetchall_w_bqstorage_client_fetch_no_rows(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import dbapi

mock_client = self._mock_client(
Expand Down Expand Up @@ -399,7 +399,7 @@ def test_fetchall_w_bqstorage_client_fetch_no_rows(self):
self.assertEqual(rows, [])

def test_fetchall_w_bqstorage_client_fetch_error_no_fallback(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import dbapi

row_data = [bq_table.Row([1.1, 1.2], {"foo": 0, "bar": 1})]
Expand Down Expand Up @@ -435,7 +435,7 @@ def fake_ensure_bqstorage_client(bqstorage_client=None, **kwargs):
mock_client.list_rows.assert_not_called()

def test_fetchall_w_bqstorage_client_no_arrow_compression(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pyarrow")
from google.cloud import bigquery_storage
from google.cloud.bigquery import dbapi
Expand Down
44 changes: 22 additions & 22 deletions tests/unit/test_table.py
Expand Up @@ -2327,7 +2327,7 @@ def test__should_use_bqstorage_returns_false_when_completely_cached(self):
)

def test__should_use_bqstorage_returns_true_if_no_cached_results(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
iterator = self._make_one(first_page_response=None) # not cached
result = iterator._should_use_bqstorage(
bqstorage_client=None, create_bqstorage_client=True
Expand Down Expand Up @@ -2371,7 +2371,7 @@ def fail_bqstorage_import(name, globals, locals, fromlist, level):
self.assertFalse(result)

def test__should_use_bqstorage_returns_false_w_warning_if_obsolete_version(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
iterator = self._make_one(first_page_response=None) # not cached

patcher = mock.patch(
Expand Down Expand Up @@ -2495,7 +2495,7 @@ def test_to_arrow_iterable(self):

def test_to_arrow_iterable_w_bqstorage(self):
pyarrow = pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud import bigquery_storage
from google.cloud.bigquery_storage_v1 import reader
from google.cloud.bigquery_storage_v1.services.big_query_read.transports import (
Expand Down Expand Up @@ -2783,7 +2783,7 @@ def test_to_arrow_w_empty_table(self):

def test_to_arrow_max_results_w_explicit_bqstorage_client_warning(self):
pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery.schema import SchemaField

schema = [
Expand Down Expand Up @@ -2825,7 +2825,7 @@ def test_to_arrow_max_results_w_explicit_bqstorage_client_warning(self):

def test_to_arrow_max_results_w_create_bqstorage_client_no_warning(self):
pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery.schema import SchemaField

schema = [
Expand Down Expand Up @@ -2863,7 +2863,7 @@ def test_to_arrow_max_results_w_create_bqstorage_client_no_warning(self):

def test_to_arrow_w_bqstorage(self):
pyarrow = pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -2946,7 +2946,7 @@ def test_to_arrow_w_bqstorage(self):

def test_to_arrow_w_bqstorage_creates_client(self):
pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -3012,7 +3012,7 @@ def mock_verify_version(raise_if_error: bool = False):

def test_to_arrow_w_bqstorage_no_streams(self):
pyarrow = pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -3185,7 +3185,7 @@ def test_to_dataframe_iterable_with_dtypes(self):
def test_to_dataframe_iterable_w_bqstorage(self):
pandas = pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -3258,7 +3258,7 @@ def test_to_dataframe_iterable_w_bqstorage(self):

def test_to_dataframe_iterable_w_bqstorage_max_results_warning(self):
pandas = pytest.importorskip("pandas")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -4145,7 +4145,7 @@ def test_to_dataframe_max_results_w_create_bqstorage_client_no_warning(self):

def test_to_dataframe_w_bqstorage_creates_client(self):
pytest.importorskip("pandas")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -4178,7 +4178,7 @@ def test_to_dataframe_w_bqstorage_creates_client(self):

def test_to_dataframe_w_bqstorage_no_streams(self):
pytest.importorskip("pandas")
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut
from google.cloud import bigquery_storage
Expand All @@ -4205,7 +4205,7 @@ def test_to_dataframe_w_bqstorage_no_streams(self):
self.assertTrue(got.empty)

def test_to_dataframe_w_bqstorage_logs_session(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
pytest.importorskip("pyarrow")
from google.cloud.bigquery.table import Table
Expand All @@ -4229,7 +4229,7 @@ def test_to_dataframe_w_bqstorage_logs_session(self):
)

def test_to_dataframe_w_bqstorage_empty_streams(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -4365,7 +4365,7 @@ def test_to_dataframe_w_bqstorage_nonempty(self):
bqstorage_client._transport.grpc_channel.close.assert_not_called()

def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index(self):
bigquery_storage = pytest.importorskip("google.cloud.bigquery-storage")
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
from google.cloud.bigquery import schema
Expand Down Expand Up @@ -4417,7 +4417,7 @@ def test_to_dataframe_w_bqstorage_multiple_streams_return_unique_index(self):
self.assertTrue(got.index.is_unique)

def test_to_dataframe_w_bqstorage_updates_progress_bar(self):
bigquery_storage = pytest.importorskip("google.cloud.bigquery-storage")
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
pytest.importorskip("tqdm")
Expand Down Expand Up @@ -4494,7 +4494,7 @@ def blocking_to_arrow(*args, **kwargs):
tqdm_mock().close.assert_called_once()

def test_to_dataframe_w_bqstorage_exits_on_keyboardinterrupt(self):
bigquery_storage = pytest.importorskip("google.cloud.bigquery-storage")
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
from google.cloud.bigquery import schema
Expand Down Expand Up @@ -4612,7 +4612,7 @@ def test_to_dataframe_tabledata_list_w_multiple_pages_return_unique_index(self):
self.assertTrue(df.index.is_unique)

def test_to_dataframe_w_bqstorage_raises_auth_error(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pytest.importorskip("pandas")
from google.cloud import bigquery_storage
from google.cloud.bigquery import table as mut
Expand All @@ -4633,7 +4633,7 @@ def test_to_dataframe_w_bqstorage_raises_auth_error(self):
row_iterator.to_dataframe(bqstorage_client=bqstorage_client)

def test_to_dataframe_w_bqstorage_partition(self):
bigquery_storage = pytest.importorskip("google.cloud.bigquery-storage")
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut

Expand All @@ -4651,7 +4651,7 @@ def test_to_dataframe_w_bqstorage_partition(self):
row_iterator.to_dataframe(bqstorage_client)

def test_to_dataframe_w_bqstorage_snapshot(self):
bigquery_storage = pytest.importorskip("google.cloud.bigquery-storage")
bigquery_storage = pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import schema
from google.cloud.bigquery import table as mut

Expand All @@ -4669,7 +4669,7 @@ def test_to_dataframe_w_bqstorage_snapshot(self):
row_iterator.to_dataframe(bqstorage_client)

def test_to_dataframe_concat_categorical_dtype_w_pyarrow(self):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
pandas = pytest.importorskip("pandas")
pyarrow = pytest.importorskip("pyarrow")
from google.cloud import bigquery_storage
Expand Down Expand Up @@ -5654,7 +5654,7 @@ def test_from_api_repr_only_foreign_keys_resource(self):
),
)
def test_table_reference_to_bqstorage_v1_stable(table_path):
pytest.importorskip("google.cloud.bigquery-storage")
pytest.importorskip("google.cloud.bigquery_storage")
from google.cloud.bigquery import table as mut

expected = "projects/my-project/datasets/my_dataset/tables/my_table"
Expand Down