Skip to content

Commit

Permalink
Fix hook not passing gcp_conn_id to base class (#10075)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Olszewski <kamil.olszewski@polidea.com>
  • Loading branch information
olchas and Kamil Olszewski committed Aug 2, 2020
1 parent ca3fa76 commit 4ee35d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Expand Up @@ -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):
Expand Down
Expand Up @@ -26,7 +26,9 @@
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):
Expand All @@ -37,6 +39,21 @@ def setUp(self):
):
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"
Expand Down

0 comments on commit 4ee35d0

Please sign in to comment.