Skip to content

Fix LookerHook serialize missing 1 argument error #34678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/hooks/looker.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def get_looker_sdk(self):
return methods40.Looker40SDK(
auth_session.AuthSession(settings, transport, serialize.deserialize40, "4.0"),
serialize.deserialize40,
serialize.serialize,
serialize.serialize40,
transport,
"4.0",
)
Expand Down
25 changes: 25 additions & 0 deletions tests/providers/google/cloud/hooks/test_looker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

from contextlib import nullcontext as does_not_raise
from unittest import mock

import pytest
Expand All @@ -42,6 +43,30 @@ def setup_method(self):
conn.return_value.extra_dejson = CONN_EXTRA
self.hook = LookerHook(looker_conn_id="test")

@mock.patch("airflow.providers.google.cloud.hooks.looker.requests_transport")
def test_get_looker_sdk(self, _):
"""
Test that get_looker_sdk is setting up the sdk properly

Note: `requests_transport` is mocked so we don't have to test
looker_sdk's functionality, just LookerHook's usage of it
"""
self.hook.get_connection = mock.MagicMock()
sdk = self.hook.get_looker_sdk()

# Attempting to use the instantiated SDK should not throw an error
with does_not_raise():
sdk.get(path="/", structure=None)
sdk.delete(path="/", structure=None)

# The post/patch/put methods call a method internally to serialize
# the body if LookerHook sets the wrong serialize function on init
# there will be TypeErrors thrown
# The body we pass here must be a list, dict, or model.Model
sdk.post(path="/", structure=None, body=[])
sdk.patch(path="/", structure=None, body=[])
sdk.put(path="/", structure=None, body=[])

@mock.patch(HOOK_PATH.format("pdt_build_status"))
def test_wait_for_job(self, mock_pdt_build_status):
# replace pdt_build_status invocation with mock status
Expand Down