feat(tui): clarify monitoring continuity and quitting
This commit is contained in:
@@ -415,6 +415,131 @@ class TestServiceFacts:
|
||||
assert "last collect:" in result
|
||||
assert "freshness:" in result
|
||||
|
||||
def test_continuity_reports_boot_enabled_independently_of_runtime(self, tmp_path):
|
||||
"""Status names reboot continuity while retaining the timer fact."""
|
||||
from fenris.status import get_status
|
||||
|
||||
db = tmp_path / "observations.db"
|
||||
init_store(db)
|
||||
now = datetime(2026, 9, 1, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
with patch("fenris.status.query_service_state", return_value={
|
||||
"boot_enabled": True, "timer_active": False,
|
||||
"last_collect_ok": None, "last_collect_age_s": None,
|
||||
"last_collect_reason": None,
|
||||
}):
|
||||
result = get_status(store_path=db, clock_now=now,
|
||||
query_services=True, query_journal=False)
|
||||
|
||||
assert "monitoring: active in background · persists across reboots" in result
|
||||
assert "timer: inactive" in result
|
||||
|
||||
def test_continuity_and_deliberate_pause_are_reported_separately(self, tmp_path):
|
||||
"""Only a sanctioned user_disabled period renders the paused wording."""
|
||||
from fenris.status import get_status
|
||||
|
||||
db = tmp_path / "observations.db"
|
||||
conn = init_store(db)
|
||||
conn.execute(
|
||||
"INSERT INTO monitoring_periods (started_at, ended_at, end_cause) "
|
||||
"VALUES (?, ?, ?)",
|
||||
("2026-09-01T09:00:00+00:00", "2026-09-01T10:00:00+00:00", "user_disabled"),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
now = datetime(2026, 9, 1, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
with patch("fenris.status.query_service_state", return_value={
|
||||
"boot_enabled": False, "timer_active": False,
|
||||
"last_collect_ok": None, "last_collect_age_s": None,
|
||||
"last_collect_reason": None,
|
||||
}):
|
||||
result = get_status(store_path=db, clock_now=now,
|
||||
query_services=True, query_journal=False)
|
||||
|
||||
assert "monitoring: does not start on next boot" in result
|
||||
assert "monitoring: paused — deliberate disable" in result
|
||||
assert "paused time is excluded from your usage habit · resume: fenris monitor resume" in result
|
||||
|
||||
def test_raw_system_state_without_user_disabled_is_not_a_deliberate_pause(self, tmp_path):
|
||||
"""A non-sanctioned stop never acquires the deliberate-disable label."""
|
||||
from fenris.status import get_status
|
||||
|
||||
db = tmp_path / "observations.db"
|
||||
conn = init_store(db)
|
||||
conn.execute(
|
||||
"INSERT INTO monitoring_periods (started_at, ended_at, end_cause) "
|
||||
"VALUES (?, ?, ?)",
|
||||
("2026-09-01T09:00:00+00:00", "2026-09-01T10:00:00+00:00", "migrated"),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
now = datetime(2026, 9, 1, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
with patch("fenris.status.query_service_state", return_value={
|
||||
"boot_enabled": False, "timer_active": False,
|
||||
"last_collect_ok": None, "last_collect_age_s": None,
|
||||
"last_collect_reason": None,
|
||||
}):
|
||||
result = get_status(store_path=db, clock_now=now,
|
||||
query_services=True, query_journal=False)
|
||||
|
||||
assert "monitoring: paused — deliberate disable" not in result
|
||||
|
||||
def test_resumed_open_period_clears_a_previous_deliberate_pause(self, tmp_path):
|
||||
"""A later sanctioned resume takes precedence over an older pause."""
|
||||
from fenris.status import get_status
|
||||
|
||||
db = tmp_path / "observations.db"
|
||||
conn = init_store(db)
|
||||
conn.execute(
|
||||
"INSERT INTO monitoring_periods (started_at, ended_at, end_cause) "
|
||||
"VALUES (?, ?, ?)",
|
||||
("2026-09-01T09:00:00+00:00", "2026-09-01T10:00:00+00:00", "user_disabled"),
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO monitoring_periods (started_at) VALUES (?)",
|
||||
("2026-09-01T11:00:00+00:00",),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
now = datetime(2026, 9, 1, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
with patch("fenris.status.query_service_state", return_value={
|
||||
"boot_enabled": True, "timer_active": True,
|
||||
"last_collect_ok": None, "last_collect_age_s": None,
|
||||
"last_collect_reason": None,
|
||||
}):
|
||||
result = get_status(store_path=db, clock_now=now,
|
||||
query_services=True, query_journal=False)
|
||||
|
||||
assert "monitoring: paused — deliberate disable" not in result
|
||||
|
||||
def test_live_enabled_service_suppresses_a_stale_pause_marker(self, tmp_path):
|
||||
"""A raw re-enable cannot leave a contradictory paused presentation."""
|
||||
from fenris.status import get_status
|
||||
|
||||
db = tmp_path / "observations.db"
|
||||
conn = init_store(db)
|
||||
conn.execute(
|
||||
"INSERT INTO monitoring_periods (started_at, ended_at, end_cause) "
|
||||
"VALUES (?, ?, ?)",
|
||||
("2026-09-01T09:00:00+00:00", "2026-09-01T10:00:00+00:00", "user_disabled"),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
now = datetime(2026, 9, 1, 12, 0, 0, tzinfo=timezone.utc)
|
||||
|
||||
with patch("fenris.status.query_service_state", return_value={
|
||||
"boot_enabled": True, "timer_active": True,
|
||||
"last_collect_ok": None, "last_collect_age_s": None,
|
||||
"last_collect_reason": None,
|
||||
}):
|
||||
result = get_status(store_path=db, clock_now=now,
|
||||
query_services=True, query_journal=False)
|
||||
|
||||
assert "monitoring: paused — deliberate disable" not in result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Status output structure (§8.8, LC-9)
|
||||
|
||||
Reference in New Issue
Block a user