From e0f65d7ff582b32f1c7b5508bba8cda807aaae5f Mon Sep 17 00:00:00 2001
From: Dennis Fink
Date: Sat, 15 Aug 2026 20:54:53 +0200
Subject: feat(sender): add outgoing Webmention pipeline
Scan generated h-entry documents for Webmention targets and track source
revisions and delivery state in the database.
Discover target endpoints, send Webmentions asynchronously, and reconcile
updated, removed, restored, and deleted sources across scans.
Add authenticated views for inspecting sent Webmentions and make the scanner
schedule configurable.
---
tests/tasks/test_receiver.py | 396 +++--------
tests/tasks/test_scanner.py | 1558 ++++++++++++++++++++++++++++++++++++++++++
tests/tasks/test_sender.py | 788 +++++++++++++++++++++
tests/test_forms.py | 80 +--
tests/test_url_security.py | 54 +-
tests/test_views.py | 202 ++++--
6 files changed, 2653 insertions(+), 425 deletions(-)
create mode 100644 tests/tasks/test_scanner.py
create mode 100644 tests/tasks/test_sender.py
(limited to 'tests')
diff --git a/tests/tasks/test_receiver.py b/tests/tasks/test_receiver.py
index 19630c3..811ab63 100644
--- a/tests/tasks/test_receiver.py
+++ b/tests/tasks/test_receiver.py
@@ -9,10 +9,7 @@ from flask import Flask
from webmentions_ssg import DATABASE as db
from webmentions_ssg.models import ReceivedWebmention
-from webmentions_ssg.url_security import (
- AddressResolutionError,
- NonPublicAddressError,
-)
+from webmentions_ssg.url_security import AddressResolutionError
SOURCE_URL = "https://source.example/article"
TARGET_URL = "https://dennisfink.me/blog/example/"
@@ -50,28 +47,16 @@ def create_webmention(
return identifier
-def get_webmention_state(
- app: Flask,
- identifier: uuid.UUID,
-) -> tuple[str, str | None]:
+def get_webmention_state(app: Flask, identifier: uuid.UUID) -> tuple[str, str | None]:
with app.app_context():
- webmention = db.session.get(
- ReceivedWebmention,
- identifier,
- )
+ webmention = db.session.get(ReceivedWebmention, identifier)
assert webmention is not None
- return (
- webmention.status,
- webmention.failure_reason,
- )
+ return (webmention.status, webmention.failure_reason)
-def set_stream_response(
- httpx_client: Mock,
- response: httpx.Response,
-) -> Mock:
+def set_stream_response(httpx_client: Mock, response: httpx.Response) -> Mock:
client = httpx_client.return_value.__enter__.return_value
client.stream.return_value.__enter__.return_value = response
return client
@@ -80,65 +65,25 @@ def set_stream_response(
@pytest.mark.parametrize(
("body", "expected"),
[
+ pytest.param(f'Reply', True, id="a-href"),
+ pytest.param(f'', True, id="area-href"),
pytest.param(
- f'Reply',
- True,
- id="a-href",
- ),
- pytest.param(
- f'',
- True,
- id="area-href",
- ),
- pytest.param(
- f'',
- True,
- id="link-href",
- ),
- pytest.param(
- f'
',
- True,
- id="img-src",
- ),
- pytest.param(
- f'',
- True,
- id="audio-src",
- ),
- pytest.param(
- f'',
- True,
- id="video-src",
- ),
- pytest.param(
- f'',
- True,
- id="audio-source-src",
+ f'', True, id="link-href"
),
+ pytest.param(f'
', True, id="img-src"),
+ pytest.param(f'', True, id="audio-src"),
+ pytest.param(f'', True, id="video-src"),
pytest.param(
- f'',
- True,
- id="video-source-src",
+ f'', True, id="audio-source-src"
),
pytest.param(
- f'',
- True,
- id="iframe-src",
+ f'', True, id="video-source-src"
),
+ pytest.param(f'', True, id="iframe-src"),
+ pytest.param(f'