From e4529153ffcfd35617cd8aee5b6b894974703081 Mon Sep 17 00:00:00 2001 From: Joonhyung Shin Date: Thu, 8 Aug 2024 01:31:20 -0500 Subject: [PATCH] Make black happy --- storages/backends/gcloud.py | 2 +- tests/test_gcloud.py | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/storages/backends/gcloud.py b/storages/backends/gcloud.py index 519bfb79..8732e75f 100644 --- a/storages/backends/gcloud.py +++ b/storages/backends/gcloud.py @@ -155,7 +155,7 @@ def client(self): if self._client is None: if self.iam_sign_blob and not self.credentials: self.credentials, self.project_id = auth.default( - scopes=['https://www.googleapis.com/auth/cloud-platform'] + scopes=["https://www.googleapis.com/auth/cloud-platform"] ) self._client = Client(project=self.project_id, credentials=self.credentials) return self._client diff --git a/tests/test_gcloud.py b/tests/test_gcloud.py index 7ec4fa0f..e7e44c50 100644 --- a/tests/test_gcloud.py +++ b/tests/test_gcloud.py @@ -511,24 +511,18 @@ def test_dupe_file_chunk_size(self): def test_iam_sign_blob_setting(self): self.assertEqual(self.storage.iam_sign_blob, False) - with override_settings( - GS_IAM_SIGN_BLOB=True - ): + with override_settings(GS_IAM_SIGN_BLOB=True): storage = gcloud.GoogleCloudStorage() self.assertEqual(storage.iam_sign_blob, True) def test_sa_email_setting(self): self.assertEqual(self.storage.sa_email, None) - with override_settings( - GS_SA_EMAIL="service_account_email@gmail.com" - ): + with override_settings(GS_SA_EMAIL="service_account_email@gmail.com"): storage = gcloud.GoogleCloudStorage() self.assertEqual(storage.sa_email, "service_account_email@gmail.com") def test_iam_sign_blob_no_service_account_email_raises_attribute_error(self): - with override_settings( - GS_IAM_SIGN_BLOB=True - ): + with override_settings(GS_IAM_SIGN_BLOB=True): storage = gcloud.GoogleCloudStorage() storage._bucket = mock.MagicMock() storage.credentials = mock.MagicMock() @@ -537,16 +531,17 @@ def test_iam_sign_blob_no_service_account_email_raises_attribute_error(self): # simulating access token storage.credentials.token = "1234" # no sa_email or adc service_account_email found - with self.assertRaises(AttributeError, msg=( - "Sign Blob API requires service_account_email to be available " - "through ADC or setting `sa_email`" - )): + with self.assertRaises( + AttributeError, + msg=( + "Sign Blob API requires service_account_email to be available " + "through ADC or setting `sa_email`" + ), + ): storage.url(self.filename) def test_iam_sign_blob_with_adc_service_account_email(self): - with override_settings( - GS_IAM_SIGN_BLOB=True - ): + with override_settings(GS_IAM_SIGN_BLOB=True): storage = gcloud.GoogleCloudStorage() storage._bucket = mock.MagicMock() storage.credentials = mock.MagicMock() @@ -562,13 +557,12 @@ def test_iam_sign_blob_with_adc_service_account_email(self): expiration=timedelta(seconds=86400), version="v4", service_account_email=storage.credentials.service_account_email, - access_token=storage.credentials.token + access_token=storage.credentials.token, ) def test_iam_sign_blob_with_sa_email_setting(self): with override_settings( - GS_IAM_SIGN_BLOB=True, - GS_SA_EMAIL="service_account_email@gmail.com" + GS_IAM_SIGN_BLOB=True, GS_SA_EMAIL="service_account_email@gmail.com" ): storage = gcloud.GoogleCloudStorage() storage._bucket = mock.MagicMock() @@ -585,7 +579,7 @@ def test_iam_sign_blob_with_sa_email_setting(self): expiration=timedelta(seconds=86400), version="v4", service_account_email=storage.sa_email, - access_token=storage.credentials.token + access_token=storage.credentials.token, )