aboutsummaryrefslogtreecommitdiff
path: root/tests/tasks/test_scanner.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 22:12:02 +0100
committerDennis Fink2026-11-13 22:12:02 +0100
commit2366d455c7d1ae16c84e0bcbffb94ed762c16832 (patch)
tree51de07737ebc12fdcbf29a0a405ff2cd5aa9eb87 /tests/tasks/test_scanner.py
parent64f328d86bba9caa9d0a60aa89e06f70403942b9 (diff)
downloadwebmentions-ssg-2366d455c7d1ae16c84e0bcbffb94ed762c16832.tar.gz
webmentions-ssg-2366d455c7d1ae16c84e0bcbffb94ed762c16832.zip
refactor(core): split task workflows into focused helpers
Decompose receiver verification, source scanning, and Webmention delivery into explicit claim, check, reconciliation, and outcome-recording stages. Extract Huey backend parsing helpers and add focused tests for the new task boundaries while preserving existing processing semantics.
Diffstat (limited to '')
-rw-r--r--tests/tasks/test_scanner.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/tasks/test_scanner.py b/tests/tasks/test_scanner.py
index c0b9223..d16729c 100644
--- a/tests/tasks/test_scanner.py
+++ b/tests/tasks/test_scanner.py
@@ -82,6 +82,39 @@ def test_manual_scan_propagates_unrelated_errors(
scanner_module.manual_scan_sources.call_local()
+def test_scan_tree_returns_count_and_seen_paths(
+ app: Flask, scanner_module: ModuleType, tmp_path: Path, monkeypatch: MonkeyPatch
+) -> None:
+ for name in ("good", "bad"):
+ directory = tmp_path / name
+ directory.mkdir()
+ (directory / "index.html").write_text("<html></html>")
+
+ def parse(index_path: Path, **kwargs: Any) -> source_parser.ScannedSource:
+ if index_path.parent.name == "bad":
+ raise source_parser.SourceScanError("Unparseable source")
+ return source_parser.ScannedSource(
+ path="good/index.html",
+ url=f"{BASE_URL}good/",
+ content_hash="0" * 32,
+ targets=frozenset(),
+ )
+
+ monkeypatch.setattr(scanner_module, "scan_source_file", parse)
+ sources: dict[str, Source] = {}
+ urls: dict[str, str] = {}
+
+ with app.app_context():
+ scan = scanner_module.scan_tree(
+ tmp_path, BASE_URL, sources, urls, datetime.now(UTC)
+ )
+
+ assert scan.scanned_count == 1
+ assert scan.seen_paths == frozenset({"good/index.html", "bad/index.html"})
+ assert list(sources) == ["good/index.html"]
+ assert urls == {f"{BASE_URL}good/": "good/index.html"}
+
+
def test_scan_creates_source_and_webmentions(
app: Flask, scanner_module: ModuleType, tmp_path: Path, monkeypatch: MonkeyPatch
) -> None: