aboutsummaryrefslogtreecommitdiff
path: root/tests/test_models.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 20:49:15 +0100
committerDennis Fink2026-11-13 20:49:15 +0100
commitca71bf1f30e118dd5bade3cff817d5bbd09f680a (patch)
tree9c20d8e948581eb7689eacc9e531360ab7b459ff /tests/test_models.py
parent82495162be98323fc56a35f2c2a59c143a765136 (diff)
downloadwebmentions-ssg-ca71bf1f30e118dd5bade3cff817d5bbd09f680a.tar.gz
webmentions-ssg-ca71bf1f30e118dd5bade3cff817d5bbd09f680a.zip
refactor(core): clarify Webmention mutation APIs
Make in-place reset and reopen helpers return `None` so callers no longer perform pointless self-reassignment. Split explicit resend behavior into its own method instead of hiding it behind a boolean flag on `reopen`.
Diffstat (limited to 'tests/test_models.py')
-rw-r--r--tests/test_models.py42
1 files changed, 38 insertions, 4 deletions
diff --git a/tests/test_models.py b/tests/test_models.py
index 7ec7df7..bb95be2 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -233,14 +233,14 @@ def test_received_verification_reset_is_reusable_for_atomic_updates() -> None:
failure_reason="Old error",
recovery_attempts=3,
)
- assert mention.reset_for_verification() is mention
+ assert mention.reset_for_verification() is None
assert mention.status == ReceivedStatus.RECEIVED
assert mention.failure_reason is None
assert mention.recovery_attempts == 0
assert mention.updated_at is not None
-def test_reopen_preserves_delivery_history_unless_explicit_resend() -> None:
+def test_reopen_preserves_delivery_history() -> None:
from webmentions_ssg.models import SentWebmentionStatus
sent_at = datetime.now(UTC)
@@ -255,7 +255,7 @@ def test_reopen_preserves_delivery_history_unless_explicit_resend() -> None:
next_retry_at=sent_at,
last_sent_at=sent_at,
)
- assert mention.reopen(3, False) is mention
+ assert mention.reopen(3, False) is None
assert mention.desired_revision == 3
assert mention.active is False
assert mention.attempt_count == 0
@@ -263,10 +263,44 @@ def test_reopen_preserves_delivery_history_unless_explicit_resend() -> None:
assert mention.status == SentWebmentionStatus.SENT
assert mention.sent_revision == 2
- assert mention.reopen(3, True, resend=True) is mention
+
+
+def test_resend_requeues_current_revision_without_losing_send_history() -> None:
+ from webmentions_ssg.models import SentWebmentionStatus
+
+ sent_at = datetime.now(UTC)
+ mention = SentWebmention(
+ target="https://example.com/post",
+ active=True,
+ desired_revision=3,
+ processed_revision=3,
+ sent_revision=2,
+ status=SentWebmentionStatus.FAILED,
+ failure_reason="Previous failure",
+ endpoint="https://example.com/webmention",
+ response_status=503,
+ status_url="https://example.com/status",
+ attempt_count=3,
+ next_retry_at=sent_at,
+ last_attempted_at=sent_at,
+ last_sent_at=sent_at,
+ )
+ assert not mention.pending
+
+ assert mention.resend() is None
+ assert mention.desired_revision == 3
+ assert mention.active is True
+ assert mention.pending
assert mention.processed_revision is None
assert mention.status is None
+ assert mention.failure_reason is None
+ assert mention.endpoint is None
+ assert mention.response_status is None
+ assert mention.status_url is None
+ assert mention.attempt_count == 0
+ assert mention.next_retry_at is None
assert mention.sent_revision == 2
+ assert mention.last_attempted_at == sent_at
assert mention.last_sent_at == sent_at