@@ -1766,3 +1766,50 @@ def test_fabric_pyodbc_connection_string_generation():
17661766
17671767 # Check autocommit parameter, should default to True for Fabric
17681768 assert call_args [1 ]["autocommit" ] is True
1769+
1770+
1771+ def test_mssql_driver_defaults (make_config ):
1772+ """Test driver defaults for MSSQL connection config.
1773+
1774+ Ensures MSSQL defaults to 'pymssql' but can be overridden to 'pyodbc'.
1775+ """
1776+
1777+ # Test 1: MSSQL with no driver specified - should default to pymssql
1778+ config_no_driver = make_config (type = "mssql" , host = "localhost" , check_import = False )
1779+ assert isinstance (config_no_driver , MSSQLConnectionConfig )
1780+ assert config_no_driver .driver == "pymssql"
1781+
1782+ # Test 2: MSSQL with explicit pymssql driver
1783+ config_pymssql = make_config (
1784+ type = "mssql" , host = "localhost" , driver = "pymssql" , check_import = False
1785+ )
1786+ assert isinstance (config_pymssql , MSSQLConnectionConfig )
1787+ assert config_pymssql .driver == "pymssql"
1788+
1789+ # Test 3: MSSQL with explicit pyodbc driver
1790+ config_pyodbc = make_config (type = "mssql" , host = "localhost" , driver = "pyodbc" , check_import = False )
1791+ assert isinstance (config_pyodbc , MSSQLConnectionConfig )
1792+ assert config_pyodbc .driver == "pyodbc"
1793+
1794+
1795+ def test_fabric_driver_defaults (make_config ):
1796+ """Test driver defaults for Fabric connection config.
1797+
1798+ Ensures Fabric defaults to 'pyodbc' and cannot be changed to 'pymssql'.
1799+ """
1800+
1801+ # Test 1: Fabric with no driver specified - should default to pyodbc
1802+ config_no_driver = make_config (type = "fabric" , host = "localhost" , check_import = False )
1803+ assert isinstance (config_no_driver , FabricConnectionConfig )
1804+ assert config_no_driver .driver == "pyodbc"
1805+
1806+ # Test 2: Fabric with explicit pyodbc driver
1807+ config_pyodbc = make_config (
1808+ type = "fabric" , host = "localhost" , driver = "pyodbc" , check_import = False
1809+ )
1810+ assert isinstance (config_pyodbc , FabricConnectionConfig )
1811+ assert config_pyodbc .driver == "pyodbc"
1812+
1813+ # Test 3: Fabric with pymssql driver should fail (not allowed)
1814+ with pytest .raises (ConfigError , match = r"Input should be 'pyodbc'" ):
1815+ make_config (type = "fabric" , host = "localhost" , driver = "pymssql" , check_import = False )
0 commit comments