You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/08/02 07:05:38 UTC
[airflow] branch master updated: Fix hook not passing gcp_conn_id
to base class (#10075)
This is an automated email from the ASF dual-hosted git repository.
kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 4ee35d0 Fix hook not passing gcp_conn_id to base class (#10075)
4ee35d0 is described below
commit 4ee35d027988c6456767faeb108a7f686d5117f2
Author: Kamil Olszewski <34...@users.noreply.github.com>
AuthorDate: Sun Aug 2 09:05:06 2020 +0200
Fix hook not passing gcp_conn_id to base class (#10075)
Co-authored-by: Kamil Olszewski <ka...@polidea.com>
---
.../google/marketing_platform/hooks/analytics.py | 2 --
.../google/marketing_platform/hooks/test_analytics.py | 19 ++++++++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/airflow/providers/google/marketing_platform/hooks/analytics.py b/airflow/providers/google/marketing_platform/hooks/analytics.py
index d4d5228..546ad29 100644
--- a/airflow/providers/google/marketing_platform/hooks/analytics.py
+++ b/airflow/providers/google/marketing_platform/hooks/analytics.py
@@ -31,13 +31,11 @@ class GoogleAnalyticsHook(GoogleBaseHook):
def __init__(
self,
api_version: str = "v3",
- gcp_conn_id: str = "google_cloud_default",
*args,
**kwargs
):
super().__init__(*args, **kwargs)
self.api_version = api_version
- self.gcp_connection_is = gcp_conn_id
self._conn = None
def _paginate(self, resource: Resource, list_args: Optional[Dict[str, Any]] = None):
diff --git a/tests/providers/google/marketing_platform/hooks/test_analytics.py b/tests/providers/google/marketing_platform/hooks/test_analytics.py
index 5fc5188..c073e29 100644
--- a/tests/providers/google/marketing_platform/hooks/test_analytics.py
+++ b/tests/providers/google/marketing_platform/hooks/test_analytics.py
@@ -26,7 +26,9 @@ WEB_PROPERTY_ID = "web_property_id"
ACCOUNT_ID = "the_knight_who_says_ni!"
DATA_SOURCE = "Monthy Python"
API_VERSION = "v3"
-GCP_CONN_ID = "google_cloud_default"
+GCP_CONN_ID = "test_gcp_conn_id"
+DELEGATE_TO = "TEST_DELEGATE_TO"
+IMPERSONATION_CHAIN = ["ACCOUNT_1", "ACCOUNT_2", "ACCOUNT_3"]
class TestGoogleAnalyticsHook(unittest.TestCase):
@@ -37,6 +39,21 @@ class TestGoogleAnalyticsHook(unittest.TestCase):
):
self.hook = GoogleAnalyticsHook(API_VERSION, GCP_CONN_ID)
+ @mock.patch("airflow.providers.google.common.hooks.base_google.GoogleBaseHook.__init__")
+ def test_init(self, mock_base_init):
+ hook = GoogleAnalyticsHook(
+ API_VERSION,
+ GCP_CONN_ID,
+ delegate_to=DELEGATE_TO,
+ impersonation_chain=IMPERSONATION_CHAIN,
+ )
+ mock_base_init.assert_called_once_with(
+ GCP_CONN_ID,
+ delegate_to=DELEGATE_TO,
+ impersonation_chain=IMPERSONATION_CHAIN,
+ )
+ self.assertEqual(hook.api_version, API_VERSION)
+
@mock.patch(
"airflow.providers.google.marketing_platform.hooks."
"analytics.GoogleAnalyticsHook._authorize"