Skip to content

Commit 4ee35d0

Browse files
olchasKamil Olszewski
andauthored
Fix hook not passing gcp_conn_id to base class (#10075)
Co-authored-by: Kamil Olszewski <kamil.olszewski@polidea.com>
1 parent ca3fa76 commit 4ee35d0

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

β€Žairflow/providers/google/marketing_platform/hooks/analytics.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ class GoogleAnalyticsHook(GoogleBaseHook):
3131
def __init__(
3232
self,
3333
api_version: str = "v3",
34-
gcp_conn_id: str = "google_cloud_default",
3534
*args,
3635
**kwargs
3736
):
3837
super().__init__(*args, **kwargs)
3938
self.api_version = api_version
40-
self.gcp_connection_is = gcp_conn_id
4139
self._conn = None
4240

4341
def _paginate(self, resource: Resource, list_args: Optional[Dict[str, Any]] = None):

β€Žtests/providers/google/marketing_platform/hooks/test_analytics.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
ACCOUNT_ID = "the_knight_who_says_ni!"
2727
DATA_SOURCE = "Monthy Python"
2828
API_VERSION = "v3"
29-
GCP_CONN_ID = "google_cloud_default"
29+
GCP_CONN_ID = "test_gcp_conn_id"
30+
DELEGATE_TO = "TEST_DELEGATE_TO"
31+
IMPERSONATION_CHAIN = ["ACCOUNT_1", "ACCOUNT_2", "ACCOUNT_3"]
3032

3133

3234
class TestGoogleAnalyticsHook(unittest.TestCase):
@@ -37,6 +39,21 @@ def setUp(self):
3739
):
3840
self.hook = GoogleAnalyticsHook(API_VERSION, GCP_CONN_ID)
3941

42+
@mock.patch("airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__")
43+
def test_init(self, mock_base_init):
44+
hook = GoogleAnalyticsHook(
45+
API_VERSION,
46+
GCP_CONN_ID,
47+
delegate_to=DELEGATE_TO,
48+
impersonation_chain=IMPERSONATION_CHAIN,
49+
)
50+
mock_base_init.assert_called_once_with(
51+
GCP_CONN_ID,
52+
delegate_to=DELEGATE_TO,
53+
impersonation_chain=IMPERSONATION_CHAIN,
54+
)
55+
self.assertEqual(hook.api_version, API_VERSION)
56+
4057
@mock.patch(
4158
"airflow.providers.google.marketing_platform.hooks."
4259
"analytics.GoogleAnalyticsHook._authorize"

0 commit comments

Comments
 (0)