Skip to content

Commit

Permalink
Skip BQ storage unit tests in Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Feb 14, 2020
1 parent ac89c4b commit aa34db4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion noxfile.py
Expand Up @@ -48,7 +48,7 @@ def default(session):
# Since many tests are skipped due to missing dependencies, test
# coverage is much lower in Python 3.8. Remove once we can test with
# pyarrow.
coverage_fail_under = "--cov-fail-under=92"
coverage_fail_under = "--cov-fail-under=91"
dev_install = ".[pandas,tqdm]"

session.install("-e", dev_install)
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_dbapi_connection.py
Expand Up @@ -16,6 +16,11 @@

import mock

try:
from google.cloud import bigquery_storage_v1beta1
except ImportError: # pragma: NO COVER
bigquery_storage_v1beta1 = None


class TestConnection(unittest.TestCase):
@staticmethod
Expand All @@ -39,6 +44,9 @@ def _mock_bqstorage_client(self):
mock_client = mock.create_autospec(client.BigQueryStorageClient)
return mock_client

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_ctor(self):
from google.cloud.bigquery.dbapi import Connection

Expand Down Expand Up @@ -69,6 +77,9 @@ def test_connect_w_client(self):
self.assertIsInstance(connection, Connection)
self.assertIs(connection._client, mock_client)

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_connect_w_both_clients(self):
from google.cloud.bigquery.dbapi import connect
from google.cloud.bigquery.dbapi import Connection
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_dbapi_cursor.py
Expand Up @@ -20,6 +20,11 @@

from google.api_core import exceptions

try:
from google.cloud import bigquery_storage_v1beta1
except ImportError: # pragma: NO COVER
bigquery_storage_v1beta1 = None


class TestCursor(unittest.TestCase):
@staticmethod
Expand Down Expand Up @@ -207,6 +212,9 @@ def test_fetchall_w_row(self):
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0], (1,))

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_fetchall_w_bqstorage_client_fetch_success(self):
from google.cloud.bigquery import dbapi
from google.cloud.bigquery import table
Expand Down Expand Up @@ -247,6 +255,9 @@ def test_fetchall_w_bqstorage_client_fetch_success(self):

self.assertEqual(sorted_row_data, expected_row_data)

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_fetchall_w_bqstorage_client_fetch_no_rows(self):
from google.cloud.bigquery import dbapi

Expand All @@ -267,6 +278,9 @@ def test_fetchall_w_bqstorage_client_fetch_no_rows(self):
# check the data returned
self.assertEqual(rows, [])

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_fetchall_w_bqstorage_client_fetch_error_no_fallback(self):
from google.cloud.bigquery import dbapi
from google.cloud.bigquery import table
Expand All @@ -292,6 +306,9 @@ def test_fetchall_w_bqstorage_client_fetch_error_no_fallback(self):
# the default client was not used
mock_client.list_rows.assert_not_called()

@unittest.skipIf(
bigquery_storage_v1beta1 is None, "Requires `google-cloud-bigquery-storage`"
)
def test_fetchall_w_bqstorage_client_fetch_error_fallback_on_client(self):
from google.cloud.bigquery import dbapi
from google.cloud.bigquery import table
Expand Down

0 comments on commit aa34db4

Please sign in to comment.