aboutsummaryrefslogtreecommitdiff
path: root/tests/tasks
diff options
context:
space:
mode:
authorDennis Fink2026-11-18 08:01:26 +0100
committerDennis Fink2026-11-18 08:01:26 +0100
commitb908ee61770dc78f8d8fbbbfc4f3c00d7877d42a (patch)
tree322d85654e5518c2836ce57beafaa7e2abaab741 /tests/tasks
parent63af533d98aac82b6d4f069b217d3e837285508d (diff)
downloadwebmentions-ssg-b908ee61770dc78f8d8fbbbfc4f3c00d7877d42a.tar.gz
webmentions-ssg-b908ee61770dc78f8d8fbbbfc4f3c00d7877d42a.zip
feat(core): add dashboard overview
Replace the root redirect with an authenticated dashboard showing received and outgoing status counts, recent activity, pending sends, retries, and queue depth. Persist the last completed source scan so operational status survives restarts and only advances after a successful, conclusive scan.
Diffstat (limited to '')
-rw-r--r--tests/tasks/test_scanner.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/tasks/test_scanner.py b/tests/tasks/test_scanner.py
index dbeeac9..af5a64e 100644
--- a/tests/tasks/test_scanner.py
+++ b/tests/tasks/test_scanner.py
@@ -17,6 +17,7 @@ from huey.exceptions import RetryTask
from pytest import MonkeyPatch
from webmentions_ssg import db
+from webmentions_ssg.models.scan_state import ScanState
from webmentions_ssg.models.sources import (
SentWebmention,
SentWebmentionStatus,
@@ -1464,3 +1465,59 @@ def test_scan_sources_ignores_root_index(
assert len(sources) == 1
assert sources[0].path == "example/index.html"
+
+
+def test_scan_records_only_completed_source_scans(
+ app: Flask, scanner_module: ModuleType, tmp_path: Path
+) -> None:
+ configure_scanner(app, tmp_path)
+ with app.app_context():
+ assert db.session.get(ScanState, 1) is None
+
+ # Empty traversals are inconclusive and do not report completion.
+ run_scan(app, scanner_module)
+ with app.app_context():
+ assert db.session.get(ScanState, 1) is None
+
+ write_post(tmp_path, "completed", "Completed scan")
+ before = datetime.now(UTC)
+ run_scan(app, scanner_module)
+ after = datetime.now(UTC)
+ with app.app_context():
+ state = db.session.get(ScanState, 1)
+ assert state is not None
+ recorded = state.last_completed_at.replace(tzinfo=UTC)
+ assert before <= recorded <= after
+
+ # Another inconclusive pass must preserve the completion time.
+ (tmp_path / "completed" / "index.html").unlink()
+ run_scan(app, scanner_module)
+ with app.app_context():
+ state = db.session.get(ScanState, 1)
+ assert state is not None
+ assert state.last_completed_at.replace(tzinfo=UTC) == recorded
+
+
+def test_failed_scan_does_not_update_completion_time(
+ app: Flask, scanner_module: ModuleType, tmp_path: Path, monkeypatch: MonkeyPatch
+) -> None:
+ configure_scanner(app, tmp_path)
+ write_post(tmp_path, "existing", "Scan succeeded")
+ run_scan(app, scanner_module)
+
+ with app.app_context():
+ previous = db.session.get(ScanState, 1)
+ assert previous is not None
+ previous_time = previous.last_completed_at
+
+ def fail(*args: Any, **kwargs: Any) -> None:
+ raise RuntimeError("parse failed")
+
+ monkeypatch.setattr(scanner_module, "reconcile_source_tree", fail)
+ with pytest.raises(RuntimeError, match="parse failed"):
+ run_scan(app, scanner_module)
+
+ with app.app_context():
+ state = db.session.get(ScanState, 1)
+ assert state is not None
+ assert state.last_completed_at == previous_time