eldar-eln-bigabid commented on code in PR #30418:
URL: https://github.com/apache/airflow/pull/30418#discussion_r1161142935


##########
tests/providers/neo4j/hooks/test_neo4j.py:
##########
@@ -101,3 +103,33 @@ def test_run_without_schema(self, mock_graph_database):
             )
             session = 
mock_graph_database.driver.return_value.session.return_value.__enter__.return_value
             assert op_result == session.run.return_value.data.return_value
+
+    @pytest.mark.parametrize(
+        "conn_extra, expected",
+        [
+            ({"certs_self_signed": True, "neo4j_scheme": False, "encrypted": 
True}, True),
+            ({"certs_self_signed": True, "neo4j_scheme": False, "encrypted": 
False}, True),
+            ({"certs_trusted_ca": True, "neo4j_scheme": False, "encrypted": 
False}, True),
+            ({"certs_self_signed": True, "neo4j_scheme": True, "encrypted": 
False}, True),
+            ({"certs_trusted_ca": True, "neo4j_scheme": True, "encrypted": 
False}, True),
+            ({"certs_trusted_ca": False, "neo4j_scheme": False, "encrypted": 
True}, True),
+        ],
+    )
+    def test_get_client(self, conn_extra, expected):
+        connection = Connection(
+            conn_type="neo4j",
+            login="login",
+            password="password",
+            host="host",
+            schema="schema",
+            extra=conn_extra,
+        )
+        # Use the environment variable mocking to test saving the 
configuration as a URI and
+        # to avoid mocking Airflow models class
+        with mock.patch.dict("os.environ", 
AIRFLOW_CONN_NEO4J_DEFAULT=connection.get_uri()):
+            neo4j_hook = Neo4jHook()
+            is_encrypted = conn_extra.get("encrypted", False)
+            with neo4j_hook.get_client(
+                conn=connection, encrypted=is_encrypted, 
uri=neo4j_hook.get_uri(connection)
+            ) as client:
+                assert isinstance(client, Driver) == expected

Review Comment:
   I did change the test but I have some static checks that are failing since 
I've changed the implementation.. any suggestions on that?



-- 
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