"""The bundled Fabled Archives template (#5693) over the series Archives actually reported (archives_live.py): what the widget said about it.""" from plugins.prometheus import library from plugins.prometheus.template_view import render from tests.plugins.prometheus.archives_live import AT, SERIES, TARGET, latest ARCHIVES = library.bundled()[0].template def _rows(view, title): return {r.name: r for b in view.blocks if b.title == title for r in b.rows} def test_a_replication_that_never_finishes_reads_as_overdue_not_running(): view = render(ARCHIVES, TARGET, latest(), AT) assert view.tone == "crit" and view.note == "" assert view.verdict == "2 need a look. Replication: FullNightly-Restic is running, 11h 53m overdue." job = _rows(view, "Replication")["FullNightly-Restic"] assert (job.tone, job.text) == ("crit", "running") last_good, next_run = job.cells assert last_good["text"] == "—" and next_run["moment"] is not None # no good copy yet assert _rows(view, "Storage and integrity")["Malware held"].why == "above 0" def test_everything_else_archives_reported_reads_as_well(): view = render(ARCHIVES, TARGET, latest(), AT) assert all(not b.note for b in view.blocks), [b.note for b in view.blocks] steward = _rows(view, "Backup targets")["Steward"] assert (steward.tone, steward.text) == ("ok", "fresh") and steward.cells[0]["moment"] is not None storage = _rows(view, "Storage and integrity") assert storage["Disk free"].tone == "ok" and "of" in storage["Disk free"].text assert (storage["Files checked"].text, storage["Files checked"].tone) == ("100,462 of 100,462", "ok") assert storage["Notification channels failing"].tone == "ok" assert list(_rows(view, "Stored per person")) == ["Bryan Van Deusen"] assert list(_rows(view, "Running")) == ["version 2026.10.12.1717 · channel dev · commit 3605d0a"] def test_a_finished_copy_clears_it(): """The next night's run succeeds: Archives reports ok with a last good copy and deadlines a day out, and the widget says so.""" later = AT.timestamp() + 86400 done = [(labels, metric, (float(labels.endswith("state=ok")) if metric.endswith("job_state") else value)) for labels, metric, value in SERIES] done = [(lb, m, later + 30 * 3600 if m.endswith(("late_at_timestamp_seconds", "missing_at_timestamp_seconds")) and lb.startswith("job=") else v) for lb, m, v in done] job = _rows(render(ARCHIVES, TARGET, latest(done), AT), "Replication")["FullNightly-Restic"] assert (job.tone, job.text, job.why) == ("ok", "ok", "")