diff options
| author | Dennis Fink | 2026-11-19 19:42:41 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-19 20:59:24 +0100 |
| commit | 88f54d9a7699944b7d56f978e724b1c0b54dde98 (patch) | |
| tree | 88ecc527903a91a6f6622ca288b278e5875aff3d /tests/tasks/test_sender.py | |
| parent | 8ec35babe87ff8139ec23cc10b858b7481f132db (diff) | |
| download | webmentions-ssg-88f54d9a7699944b7d56f978e724b1c0b54dde98.tar.gz webmentions-ssg-88f54d9a7699944b7d56f978e724b1c0b54dde98.zip | |
feat(sender): add bulk resend and delivery history
Allow admins to resend all failed Webmentions globally or requeue every
delivery for a source using the shared confirmation workflow.
Record outgoing status history, expand sent source details, and provide
human-readable guidance for current and historical delivery failures.
Diffstat (limited to 'tests/tasks/test_sender.py')
| -rw-r--r-- | tests/tasks/test_sender.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/tasks/test_sender.py b/tests/tasks/test_sender.py index 0d68933..5be2177 100644 --- a/tests/tasks/test_sender.py +++ b/tests/tasks/test_sender.py @@ -11,12 +11,14 @@ from unittest.mock import MagicMock, Mock import httpx import pytest +import sqlalchemy as sa from flask import Flask from webmentions_ssg import db from webmentions_ssg.models.sources import ( SentWebmention, SentWebmentionStatus, + SentWebmentionStatusEvent, SourceDocument, ) @@ -184,6 +186,16 @@ def test_send_webmention_persists_success( assert webmention.last_sent_at is not None assert webmention.attempt_count == 1 assert webmention.next_retry_at is None + history = db.session.scalars( + sa.select(SentWebmentionStatusEvent).where( + SentWebmentionStatusEvent.webmention_uuid == identifier + ) + ).all() + assert len(history) == 1 + assert history[0].action == "Delivery succeeded" + assert history[0].status == SentWebmentionStatus.SENT + assert history[0].attempt_count == 1 + assert history[0].endpoint_response_status == HTTPStatus.CREATED def test_send_webmention_marks_unsupported_target_processed( @@ -221,6 +233,10 @@ def test_send_webmention_marks_unsupported_target_processed( assert webmention.endpoint_response_status is None assert webmention.status_url is None assert webmention.last_attempted_at is not None + history = db.session.scalars(sa.select(SentWebmentionStatusEvent)).all() + assert len(history) == 1 + assert history[0].action == "No endpoint discovered" + assert history[0].status == SentWebmentionStatus.NO_ENDPOINT def test_send_webmention_persists_permanent_failure( @@ -252,6 +268,10 @@ def test_send_webmention_persists_permanent_failure( assert webmention.webmention_endpoint == ENDPOINT_URL assert webmention.endpoint_response_status == HTTPStatus.BAD_REQUEST assert webmention.status_url is None + history = db.session.scalars(sa.select(SentWebmentionStatusEvent)).all() + assert len(history) == 1 + assert history[0].action == "Delivery failed" + assert history[0].failure_reason == webmention.failure_reason def test_send_webmention_persists_temporary_failure_with_backoff( @@ -291,6 +311,10 @@ def test_send_webmention_persists_temporary_failure_with_backoff( webmention.next_retry_at.replace(tzinfo=None) - webmention.last_attempted_at.replace(tzinfo=None) ).total_seconds() == 3600 + history = db.session.scalars(sa.select(SentWebmentionStatusEvent)).all() + assert len(history) == 1 + assert history[0].action == "Delivery failed; automatic retry scheduled" + assert history[0].attempt_count == 1 def test_backoff_delay_is_exponential_and_capped( |
