17
17
# under the License.
18
18
from __future__ import annotations
19
19
20
+ from contextlib import nullcontext as does_not_raise
20
21
from unittest import mock
21
22
22
23
import pytest
@@ -42,6 +43,30 @@ def setup_method(self):
42
43
conn .return_value .extra_dejson = CONN_EXTRA
43
44
self .hook = LookerHook (looker_conn_id = "test" )
44
45
46
+ @mock .patch ("airflow.providers.google.cloud.hooks.looker.requests_transport" )
47
+ def test_get_looker_sdk (self , _ ):
48
+ """
49
+ Test that get_looker_sdk is setting up the sdk properly
50
+
51
+ Note: `requests_transport` is mocked so we don't have to test
52
+ looker_sdk's functionality, just LookerHook's usage of it
53
+ """
54
+ self .hook .get_connection = mock .MagicMock ()
55
+ sdk = self .hook .get_looker_sdk ()
56
+
57
+ # Attempting to use the instantiated SDK should not throw an error
58
+ with does_not_raise ():
59
+ sdk .get (path = "/" , structure = None )
60
+ sdk .delete (path = "/" , structure = None )
61
+
62
+ # The post/patch/put methods call a method internally to serialize
63
+ # the body if LookerHook sets the wrong serialize function on init
64
+ # there will be TypeErrors thrown
65
+ # The body we pass here must be a list, dict, or model.Model
66
+ sdk .post (path = "/" , structure = None , body = [])
67
+ sdk .patch (path = "/" , structure = None , body = [])
68
+ sdk .put (path = "/" , structure = None , body = [])
69
+
45
70
@mock .patch (HOOK_PATH .format ("pdt_build_status" ))
46
71
def test_wait_for_job (self , mock_pdt_build_status ):
47
72
# replace pdt_build_status invocation with mock status
0 commit comments