hussein-awala commented on code in PR #30418:
URL: https://github.com/apache/airflow/pull/30418#discussion_r1157780648
##########
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:
This test is not valid, because the method `get_client` always returns an
instance of type client, we need to check if the kwarg `encrypted` is provided
or not.
Also for the test params, the method is not based on the connection extra
anymore, so we need to parameterize the uri (for the uri creation it's already
test in `test_get_uri_neo4j_scheme`).
--
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]