From db660c519b09f694f65f0dd7ca7d1bb50e27507d Mon Sep 17 00:00:00 2001 From: Austin Weisgrau Date: Tue, 21 May 2024 12:08:36 -0700 Subject: [PATCH] Small changes to get BigQuery tests working --- parsons/google/google_bigquery.py | 8 +++++--- test/test_databases/test_bigquery.py | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/parsons/google/google_bigquery.py b/parsons/google/google_bigquery.py index 53d583c957..9f0c97e8f0 100644 --- a/parsons/google/google_bigquery.py +++ b/parsons/google/google_bigquery.py @@ -163,9 +163,11 @@ def __init__( if isinstance(app_creds, Credentials): self.credentials = app_creds else: - env_credential_path = str(uuid.uuid4()) - setup_google_application_credentials(app_creds, target_env_var_name=env_credential_path) - self.credentials = load_google_application_credentials(env_credential_path) + self.env_credential_path = str(uuid.uuid4()) + setup_google_application_credentials( + app_creds, target_env_var_name=self.env_credential_path + ) + self.credentials = load_google_application_credentials(self.env_credential_path) self.project = project self.location = location diff --git a/test/test_databases/test_bigquery.py b/test/test_databases/test_bigquery.py index d0f4fc9b62..05e7671ceb 100644 --- a/test/test_databases/test_bigquery.py +++ b/test/test_databases/test_bigquery.py @@ -6,11 +6,17 @@ from google.cloud import bigquery, exceptions -from parsons import GoogleBigQuery as BigQuery +from parsons import GoogleBigQuery from parsons import Table from parsons.google.google_cloud_storage import GoogleCloudStorage +class BigQuery(GoogleBigQuery): + @mock.patch("parsons.google.google_bigquery.load_google_application_credentials") + def __init__(self, load_creds_mock, app_creds=None, **kwargs): + super().__init__(app_creds=app_creds, **kwargs) + + class FakeClient: """A Fake Storage Client used for monkey-patching."""