aboutsummaryrefslogtreecommitdiff
path: root/tests/tasks/test_receiver.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 20:03:49 +0100
committerDennis Fink2026-11-13 20:03:49 +0100
commit87117345ed6e99e5a070d919ac17139cba7b8fe4 (patch)
treed7df5d45008dd2959194e2614b87333598b85198 /tests/tasks/test_receiver.py
parent2fbe1d383650cb31f3ef8d58c04e4d4095935833 (diff)
downloadwebmentions-ssg-87117345ed6e99e5a070d919ac17139cba7b8fe4.tar.gz
webmentions-ssg-87117345ed6e99e5a070d919ac17139cba7b8fe4.zip
fix(core): make network task failures explicit
Introduce a dedicated response-size error so callers only translate expected limit violations instead of masking unrelated `ValueError` exceptions. Ensure failed sockets are always closed, remove dead discovery error handling, and log unexpected sender failures with tracebacks before recording them.
Diffstat (limited to 'tests/tasks/test_receiver.py')
-rw-r--r--tests/tasks/test_receiver.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/tasks/test_receiver.py b/tests/tasks/test_receiver.py
index 133ab56..51d1bb6 100644
--- a/tests/tasks/test_receiver.py
+++ b/tests/tasks/test_receiver.py
@@ -198,6 +198,25 @@ def test_fetch_source_rejects_streamed_oversized_body(
receiver.fetch_source(SOURCE_URL)
+@patch("webmentions_ssg.tasks.receiver.httpx.Client")
+def test_fetch_source_does_not_mask_unexpected_value_error(
+ httpx_client: Mock,
+ app: Flask,
+ receiver: ModuleType,
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ set_stream_response(
+ httpx_client,
+ httpx.Response(200, request=httpx.Request("GET", SOURCE_URL)),
+ )
+ monkeypatch.setattr(
+ receiver, "read_limited_body", Mock(side_effect=ValueError("unexpected bug"))
+ )
+
+ with app.app_context(), pytest.raises(ValueError, match="unexpected bug"):
+ receiver.fetch_source(SOURCE_URL)
+
+
@patch("webmentions_ssg.tasks.receiver.fetch_source")
@pytest.mark.parametrize(
("content_type", "body", "expected"),