RehanAhmad25 commented on code in PR #74539:
URL: https://github.com/apache/airflow/pull/74539#discussion_r4240147441
##########
providers/microsoft/mssql/tests/unit/microsoft/mssql/hooks/test_mssql.py:
##########
@@ -381,3 +381,126 @@ def test_get_extra(self, get_connection,
mssql_connections):
hook = MsSqlHook()
assert hook.get_connection().extra
+
+
+def _mssql_hook(extra: str = "{}") -> MsSqlHook:
+ conn = Connection(
+ conn_id="mssql_default",
+ conn_type="mssql",
+ host="localhost",
+ login="user",
+ password="secret",
+ schema="db",
+ port=1433,
+ extra=extra,
+ )
+ hook = MsSqlHook()
+ hook.get_connection = mock.Mock(return_value=conn)
+ return hook
+
+
+class TestMsSqlHookDbapiDriver:
+ def test_default_driver_is_pymssql(self):
+ hook = _mssql_hook()
+ assert hook.dbapi_driver == "pymssql"
+ assert hook.sqlalchemy_scheme == "mssql+pymssql"
+ assert hook.placeholder == "%s"
+
+ @pytest.mark.parametrize(
+ "extra",
+ [
+ '{"dbapi_driver": "mssql_python"}',
+ '{"DBAPI_Driver": "MSSQL_Python"}',
+ ],
+ )
+ def test_mssql_python_driver_selection(self, extra):
+ hook = _mssql_hook(extra)
+ assert hook.dbapi_driver == "mssql_python"
+ assert hook.sqlalchemy_scheme == "mssql+mssqlpython"
+
+ def test_unsupported_driver_raises(self):
Review Comment:
Added parametrized cases for "", False, 0, a list and a dict alongside
"odbc".
--
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]