fix: validate complete-day monitoring coverage
This commit is contained in:
@@ -187,6 +187,39 @@ class TestGateNoCompleteDay:
|
||||
assert any("full local observation day" in fact
|
||||
for fact in result.contributing_facts)
|
||||
|
||||
def test_day_split_by_deliberate_pause_does_not_open_gate(self, store):
|
||||
"""A complete-looking summary cannot span separate monitoring periods."""
|
||||
_insert_baseline(store)
|
||||
_insert_segment(store)
|
||||
for i in range(20):
|
||||
day = (datetime(2026, 9, 10) + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_day(store, day, bw=1024 * 1024 * 100)
|
||||
_insert_sample(store, "2026-09-30T10:00:00+00:00", pu=5)
|
||||
|
||||
store.executemany(
|
||||
"INSERT INTO monitoring_periods (started_at, ended_at, end_cause) "
|
||||
"VALUES (?, ?, ?)",
|
||||
[
|
||||
("2026-09-29T00:00:00+00:00", "2026-09-29T12:00:00+00:00", "user_disabled"),
|
||||
("2026-09-29T13:00:00+00:00", "2026-09-30T00:00:00+00:00", "user_disabled"),
|
||||
("2026-09-30T00:00:00+00:00", None, None),
|
||||
],
|
||||
)
|
||||
store.commit()
|
||||
_insert_local_day(
|
||||
store,
|
||||
"2026-09-29",
|
||||
utc_start="2026-09-29T00:00:00+00:00",
|
||||
utc_end="2026-09-30T00:00:00+00:00",
|
||||
complete=True,
|
||||
)
|
||||
|
||||
result = compute_projection(store, _clock())
|
||||
|
||||
assert result.confidence_state == ConfidenceState.UNSUPPORTED
|
||||
assert any("full local observation day" in fact
|
||||
for fact in result.contributing_facts)
|
||||
|
||||
def test_partial_but_trusted_local_activity_opens_gate(self, store):
|
||||
"""Known local intervals can coexist with an incomplete day total."""
|
||||
_insert_baseline(store)
|
||||
|
||||
@@ -211,6 +211,8 @@ class TestStalenessFact:
|
||||
_insert_baseline(conn)
|
||||
|
||||
base = datetime(2026, 9, 15, 12, 0, 0, tzinfo=timezone.utc)
|
||||
ensure_period_open(conn, base)
|
||||
conn.commit()
|
||||
for i in range(14):
|
||||
day = (base + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_day(conn, day, bw=10*1024*1024*1024)
|
||||
@@ -234,6 +236,8 @@ class TestStalenessFact:
|
||||
_insert_baseline(conn)
|
||||
|
||||
base = datetime(2026, 9, 18, 12, 0, 0, tzinfo=timezone.utc)
|
||||
ensure_period_open(conn, base)
|
||||
conn.commit()
|
||||
for i in range(14):
|
||||
day = (base + timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
_insert_day(conn, day, bw=10*1024*1024*1024)
|
||||
|
||||
+11
-2
@@ -60,6 +60,13 @@ def _clock(year=2026, month=9, day=30, hour=12):
|
||||
return datetime(year, month, day, hour, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
|
||||
class _FrozenTuiDateTime(datetime):
|
||||
@classmethod
|
||||
def now(cls, tz=None):
|
||||
instant = datetime(2026, 9, 28, 12, 0, 0, tzinfo=timezone.utc)
|
||||
return instant.replace(tzinfo=None) if tz is None else instant.astimezone(tz)
|
||||
|
||||
|
||||
def _insert_baseline(conn, tbw_tb=1.0, verified=True,
|
||||
model="Samsung SSD 970 EVO Plus 1TB"):
|
||||
conn.execute(
|
||||
@@ -1022,7 +1029,7 @@ class TestBarGraphTUI:
|
||||
assert len(graph._day_data) == 90
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_readout_updates_on_selection(self, tmp_path):
|
||||
async def test_readout_updates_on_selection(self, tmp_path, monkeypatch):
|
||||
"""Readout shows selected day info."""
|
||||
conn = init_store(tmp_path / "test.db")
|
||||
_insert_segment(conn)
|
||||
@@ -1034,6 +1041,7 @@ class TestBarGraphTUI:
|
||||
_insert_sample(conn, "2026-09-30T10:00:00+00:00")
|
||||
conn.close()
|
||||
|
||||
monkeypatch.setattr("fenris.tui.datetime", _FrozenTuiDateTime)
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
await pilot.press("v", "v")
|
||||
@@ -1056,7 +1064,7 @@ class TestBarGraphTUI:
|
||||
assert "W 0.105 GB known" in readout
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hourly_drill_down_and_back(self, tmp_path):
|
||||
async def test_hourly_drill_down_and_back(self, tmp_path, monkeypatch):
|
||||
"""Enter drills into hourly view, Esc returns to daily."""
|
||||
conn = init_store(tmp_path / "test.db")
|
||||
_insert_segment(conn)
|
||||
@@ -1073,6 +1081,7 @@ class TestBarGraphTUI:
|
||||
_insert_sample(conn, "2026-09-30T10:00:00+00:00")
|
||||
conn.close()
|
||||
|
||||
monkeypatch.setattr("fenris.tui.datetime", _FrozenTuiDateTime)
|
||||
app = FenrisTuiApp(store_path=tmp_path / "test.db")
|
||||
async with app.run_test(size=(80, 24)) as pilot:
|
||||
await pilot.press("v", "v")
|
||||
|
||||
Reference in New Issue
Block a user