33import pytest
44
55from sqlbuild .adapters .motherduck .classes .motherduck_adapter import MotherDuckAdapter
6+ from sqlbuild .adapters .motherduck .constants import MOTHERDUCK_UNSUPPORTED_DUCKDB_HELP
67from tests .unit .src .sqlbuild .adapters .motherduck ._test_types import (
78 MotherDuckAdapterDefaultsTestCase ,
89 MotherDuckConnectErrorTestCase ,
1112)
1213from tests .unit .src .sqlbuild .adapters .motherduck .helpers import (
1314 FakeDuckDbModule ,
15+ install_failing_fake_duckdb_module ,
1416 install_fake_duckdb_module ,
1517)
1618
@@ -68,13 +70,13 @@ def test_given_connection_config_when_connecting_then_uses_motherduck_database(
6870 '"Your DuckDB version (v2.0.0) is not yet supported by MotherDuck."'
6971 ),
7072 expected_error_type = "AdapterUserError" ,
71- expected_help_fragment = "stay on the last SQLBuild release that supports DuckDB 1.5" ,
73+ expected_help = MOTHERDUCK_UNSUPPORTED_DUCKDB_HELP ,
7274 ),
7375 MotherDuckConnectErrorTestCase (
7476 description = "any other connection error is raised unchanged" ,
7577 connect_error = "IO Error: unauthorized" ,
7678 expected_error_type = "FakeDuckDbError" ,
77- expected_help_fragment = None ,
79+ expected_help = None ,
7880 ),
7981 ],
8082 ids = lambda case : case .description ,
@@ -84,17 +86,13 @@ def test_given_failing_motherduck_connect_when_connecting_then_unsupported_versi
8486 monkeypatch : pytest .MonkeyPatch ,
8587) -> None :
8688 adapter : MotherDuckAdapter = MotherDuckAdapter ()
87- _ = install_fake_duckdb_module (monkeypatch , connect_error = test_case .connect_error )
89+ _ = install_failing_fake_duckdb_module (monkeypatch , connect_error = test_case .connect_error )
8890
8991 with pytest .raises (Exception ) as raised :
9092 adapter .connect ({"database" : "md:analytics" })
9193
9294 assert type (raised .value ).__name__ == test_case .expected_error_type
93- help_text : object = getattr (raised .value , "help" , None )
94- if test_case .expected_help_fragment is None :
95- assert help_text is None
96- else :
97- assert isinstance (help_text , str ) and test_case .expected_help_fragment in help_text
95+ assert getattr (raised .value , "help" , None ) == test_case .expected_help
9896
9997
10098@pytest .mark .parametrize (
0 commit comments