Skip to content

Commit 696f6b2

Browse files
committed
Fix test failures and add MotherDuck apply_database_override
- Add apply_database_override to MotherDuck adapter (was missing despite supports_multiple_databases=True) - Fix test_explorer_refresh_cursor to update store.connections instead of app.connections directly - Add missing _load_folder_async and _load_columns_async to MockHost - Fix MockTreeNode.add() to track parent references for tree traversal
1 parent 20a07ab commit 696f6b2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

sqlit/domains/connections/providers/motherduck/adapter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def supports_multiple_databases(self) -> bool:
2828
"""MotherDuck supports multiple databases."""
2929
return True
3030

31+
def apply_database_override(self, config: ConnectionConfig, database: str) -> ConnectionConfig:
32+
"""Apply a default database for unqualified queries."""
33+
if not database:
34+
return config
35+
return config.with_endpoint(database=database)
36+
3137
def connect(self, config: ConnectionConfig) -> Any:
3238
"""Connect to MotherDuck cloud database."""
3339
duckdb = self._import_driver_module(

tests/integration/test_explorer_refresh_cursor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ async def test_explorer_refresh_keeps_cursor_on_connection() -> None:
7474

7575
# Simulate refresh with a reordered connection list (e.g. discovery/sort changes).
7676
# Keep the selected connection in the middle so a jump to first/last fails.
77-
app.connections = [connections[2], connections[1], connections[0]]
77+
# Update the store so refresh picks up the new order.
78+
app.services.connection_store.connections = [connections[2], connections[1], connections[0]]
7879

7980
before_token = getattr(app, "_tree_refresh_token", None)
8081
await pilot.press("f")
@@ -143,7 +144,8 @@ async def test_explorer_refresh_keeps_cursor_when_connection_moves_folder() -> N
143144
assert app.object_tree.cursor_node == target
144145

145146
# Move the selected connection to a different folder before refresh.
146-
app.connections = [
147+
# Update the store so refresh picks up the new folder assignments.
148+
app.services.connection_store.connections = [
147149
ConnectionConfig(
148150
name="Alpha",
149151
db_type="sqlite",
@@ -177,4 +179,3 @@ async def test_explorer_refresh_keeps_cursor_when_connection_moves_folder() -> N
177179
parent = getattr(cursor, "parent", None)
178180
parent_data = getattr(parent, "data", None)
179181
assert getattr(parent_data, "name", None) == "B"
180-

tests/ui/explorer/test_refresh_cursor_restore.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ def batch_update(self):
202202
def notify(self, message, severity="info"):
203203
pass
204204

205+
def _load_folder_async(self, node, data):
206+
"""No-op for testing - folder loading is simulated manually."""
207+
pass
208+
209+
def _load_columns_async(self, node, data):
210+
"""No-op for testing - column loading is simulated manually."""
211+
pass
212+
205213

206214
@dataclass
207215
class MockColumn:

tests/ui/test_tree_schema_grouping.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,25 @@ def format_table_name(self, schema: str, name: str) -> str:
4040
class MockTreeNode:
4141
"""Mock tree node for testing."""
4242

43-
def __init__(self, label: str = "", data: tuple = None):
43+
def __init__(self, label: str = "", data: tuple = None, parent: "MockTreeNode | None" = None):
4444
self.label = label
4545
self.data = data
46+
self.parent = parent
4647
self.children: list[MockTreeNode] = []
4748
self.allow_expand = False
49+
self.is_expanded = False
4850

49-
def add(self, label: str) -> MockTreeNode:
50-
child = MockTreeNode(label)
51+
def add(self, label: str) -> "MockTreeNode":
52+
child = MockTreeNode(label, parent=self)
5153
self.children.append(child)
5254
return child
5355

54-
def add_leaf(self, label: str) -> MockTreeNode:
56+
def add_leaf(self, label: str) -> "MockTreeNode":
5557
return self.add(label)
5658

59+
def expand(self) -> None:
60+
self.is_expanded = True
61+
5762

5863
class TestSchemaGrouping:
5964
"""Test that tables are grouped by schema correctly."""

0 commit comments

Comments
 (0)