diff options
| author | Dennis Fink | 2026-11-13 20:03:49 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 20:03:49 +0100 |
| commit | 87117345ed6e99e5a070d919ac17139cba7b8fe4 (patch) | |
| tree | d7df5d45008dd2959194e2614b87333598b85198 /tests/tasks/test_sender.py | |
| parent | 2fbe1d383650cb31f3ef8d58c04e4d4095935833 (diff) | |
| download | webmentions-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 '')
| -rw-r--r-- | tests/tasks/test_sender.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/tasks/test_sender.py b/tests/tasks/test_sender.py index 94523e5..818092b 100644 --- a/tests/tasks/test_sender.py +++ b/tests/tasks/test_sender.py @@ -431,6 +431,29 @@ def test_sender_malformed_request_is_terminal( assert post.call_count == (1 if stage == "post" else 0) +def test_sender_logs_unexpected_value_error_traceback( + app: Flask, + sender_module: ModuleType, + monkeypatch: pytest.MonkeyPatch, + caplog: pytest.LogCaptureFixture, +) -> None: + identifier = create_sent_webmention(app) + _, _, discover, _ = mock_sender_requests(sender_module, monkeypatch) + discover.side_effect = ValueError("unexpected parsing bug") + + with caplog.at_level(logging.ERROR): + sender_module.send_webmention.call_local(identifier) + + assert f"Unexpected error sending SentWebmention {identifier}" in caplog.text + assert "ValueError: unexpected parsing bug" in caplog.text + with app.app_context(): + webmention = db.session.get(SentWebmention, identifier) + assert webmention is not None + assert webmention.status == SentWebmentionStatus.FAILED + assert webmention.failure_reason == "unexpected parsing bug" + assert webmention.processed_revision == 1 + + @pytest.mark.parametrize( ("target", "reason"), [ |
