ShubhamKapoor992 commented on code in PR #72025:
URL: https://github.com/apache/airflow/pull/72025#discussion_r3895865299
##########
providers/ibm/db2/tests/unit/ibm/db2/hooks/test_db2.py:
##########
@@ -150,6 +182,34 @@ def test_get_uri_with_defaults(self, mock_get_connection):
# Verify URI uses defaults
assert uri == "db2+ibm_db://:@localhost:50000/"
+ @pytest.mark.parametrize(
+ ("extra", "expected_absent"),
+ [
+ ('{"SSLServerCertificate": null}', ["SSLSERVERCERTIFICATE=None",
"SSLSERVERCERTIFICATE="]),
+ ('{"SECURITY": "SSL", "SSLServerCertificate": null}',
["SSLSERVERCERTIFICATE=None"]),
+ ],
+ )
+ @patch("airflow.providers.ibm.db2.hooks.db2.Db2Hook.get_connection")
+ def test_get_uri_skips_none_extra_values(self, mock_get_connection, extra,
expected_absent):
+ """None-valued extra keys must not be emitted in the SQLAlchemy URI
query string."""
+ conn = Connection(
+ conn_id="db2_default",
+ conn_type="db2",
+ host="localhost",
+ login="db2user",
+ password="db2pass",
+ schema="testdb",
+ port=50000,
+ extra=extra,
+ )
+ mock_get_connection.return_value = conn
+
+ hook = Db2Hook(db2_conn_id="db2_default")
+ uri = hook.get_uri()
+
+ for absent in expected_absent:
+ assert absent not in uri
Review Comment:
> Couldn't those two tests not just become one in which we assert expected
absents and the returned uri?
Thanks for your review.
We certainly can do that but it is kept separate intentionally as they
exercise distinct code paths: one builds a URI string, the other connects via
individual parameters passed to ibm_db. Merging them would obscure which path
is broken on failure.
Please let me know if you suggest I can keep them in one test.
--
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]