bluek1te commented on code in PR #24737:
URL: https://github.com/apache/airflow/pull/24737#discussion_r925839995


##########
tests/providers/hashicorp/hooks/test_vault.py:
##########
@@ -618,6 +618,33 @@ def test_kubernetes_dejson(self, mock_hvac, 
mock_get_connection):
         test_client.auth_kubernetes.assert_called_with(role="kube_role", 
jwt="data")
         test_client.is_authenticated.assert_called_with()
         assert 2 == test_hook.vault_client.kv_engine_version
+        
+    
@mock.patch("airflow.providers.hashicorp.hooks.vault.VaultHook.get_connection")
+    
@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
+    def test_client_kwargs(self, mock_hvac, mock_get_connection):
+        mock_client = mock.MagicMock()
+        mock_hvac.Client.return_value = mock_client
+        mock_connection = self.get_mock_connection()
+        mock_get_connection.return_value = mock_connection
+
+        connection_dict = {
+            "client_kwargs": {
+                "namespace": "name",
+                "timeout": 50,
+            }
+        }
+
+        mock_connection.extra_dejson.get.side_effect = connection_dict.get
+        kwargs = {
+            "vault_conn_id": "vault_conn_id",
+        }
+        with patch("builtins.open", mock_open(read_data="data")) as mock_file:
+            test_hook = VaultHook(**kwargs)
+            test_client = test_hook.get_conn()
+        mock_get_connection.assert_called_with("vault_conn_id")
+        mock_hvac.Client.assert_called_with(url='http://localhost:8180', 
namespace="name", timeout=50)

Review Comment:
   I added a param in kwargs and connection_dict that is keyed with 
"generic_arg". They both have different values and the test now makes sure that 
the value in kwargs takes precedence.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to