diff options
| author | Dennis Fink | 2026-11-21 14:49:28 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-21 14:49:28 +0100 |
| commit | ef90dc381322122ecfb9af039cf790de92807514 (patch) | |
| tree | 9b81d9726b05fbd22e738bbc29ab6ec66536c11f /tests/tasks/test_scanner.py | |
| parent | eb11fb64e9cad6fbda2065362189653416d98577 (diff) | |
| download | webmentions-ssg-ef90dc381322122ecfb9af039cf790de92807514.tar.gz webmentions-ssg-ef90dc381322122ecfb9af039cf790de92807514.zip | |
feat(sender): split source and delivery history
Add per-Webmention detail pages so delivery state, failure guidance,
status URLs, and delivery history no longer crowd the source overview.
Track source lifecycle events separately for discovery, revision,
deletion, and restoration, and add a source-level action to resend only
failed Webmentions.
Diffstat (limited to 'tests/tasks/test_scanner.py')
| -rw-r--r-- | tests/tasks/test_scanner.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/tasks/test_scanner.py b/tests/tasks/test_scanner.py index af5a64e..dae4628 100644 --- a/tests/tasks/test_scanner.py +++ b/tests/tasks/test_scanner.py @@ -1521,3 +1521,57 @@ def test_failed_scan_does_not_update_completion_time( state = db.session.get(ScanState, 1) assert state is not None assert state.last_completed_at == previous_time + + +def test_source_lifecycle_history_records_real_transitions_only( + app: Flask, scanner_module: ModuleType +) -> None: + """An unchanged rescan is not an event; changes are preserved per source.""" + from webmentions_ssg.models.sources import SourceDocumentEvent + + timestamp = datetime(2026, 11, 1, tzinfo=UTC) + original = source_parser.ScannedSource( + path="tracked/index.html", + url="https://site.example/tracked/", + content_hash="0" * 32, + targets=frozenset({"https://example.org/linked"}), + ) + changed = source_parser.ScannedSource( + path=original.path, + url=original.url, + content_hash="1" * 32, + targets=original.targets, + ) + + with app.app_context(): + source = scanner_module.build_source(original, timestamp) + db.session.add(source) + db.session.commit() + assert [(event.action, event.revision) for event in source.history_events] == [ + ("Discovered", 1) + ] + scanner_module.apply_scan_to_source( + source, original, timestamp + timedelta(days=1) + ) + assert len(source.history_events) == 1 + scanner_module.apply_scan_to_source( + source, changed, timestamp + timedelta(days=2) + ) + scanner_module.mark_missing_sources_deleted( + {source.path: source}, frozenset(), timestamp + timedelta(days=3) + ) + scanner_module.apply_scan_to_source( + source, original, timestamp + timedelta(days=4) + ) + db.session.commit() + persisted = db.session.scalars( + sa.select(SourceDocumentEvent) + .where(SourceDocumentEvent.source_uuid == source.uuid) + .order_by(SourceDocumentEvent.id) + ).all() + assert [(event.action, event.revision) for event in persisted] == [ + ("Discovered", 1), + ("Revised", 2), + ("Deleted", 3), + ("Restored", 4), + ] |
