Skip to content

Commit 8117d0b

Browse files
committed
Add unit test for numeric range incremental rendering
1 parent bc6edf1 commit 8117d0b

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""Unit test for incremental rendering with unsupported value types."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
7+
from decimal import Decimal
8+
9+
from sqlit.domains.shell.app.main import SSMSTUI
10+
11+
from tests.ui.mocks import MockConnectionStore, MockSettingsStore, build_test_services, create_test_connection
12+
13+
14+
class NumericRange:
15+
def __init__(self, lower: int, upper: int, bounds: str = "[)") -> None:
16+
self.lower = lower
17+
self.upper = upper
18+
self.bounds = bounds
19+
20+
def __str__(self) -> str:
21+
return f"NumericRange({self.lower}, {self.upper}, '{self.bounds}')"
22+
23+
24+
@pytest.mark.asyncio
25+
async def test_incremental_rendering_handles_numeric_range_values():
26+
"""Incremental rendering should not crash on unsupported value types."""
27+
connections = [create_test_connection("test-db", "sqlite")]
28+
mock_connections = MockConnectionStore(connections)
29+
mock_settings = MockSettingsStore({"theme": "tokyo-night"})
30+
31+
services = build_test_services(
32+
connection_store=mock_connections,
33+
settings_store=mock_settings,
34+
)
35+
app = SSMSTUI(services=services)
36+
37+
columns = ["id", "amount", "range"]
38+
rows = [
39+
(i + 1, Decimal(f"{i + 1}.25"), NumericRange(i, i + 2))
40+
for i in range(201)
41+
]
42+
43+
async with app.run_test(size=(120, 40)) as pilot:
44+
await pilot.pause()
45+
46+
await app._display_query_results(
47+
columns=columns,
48+
rows=rows,
49+
row_count=len(rows),
50+
truncated=False,
51+
elapsed_ms=0,
52+
)
53+
54+
for _ in range(3):
55+
await pilot.pause(0.05)
56+
57+
assert app.results_table.row_count == len(rows)

0 commit comments

Comments
 (0)