From 9b00526ab79257b65cedd71595848f09ecf84279 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sun, 15 Nov 2026 21:18:19 +0100 Subject: refactor(core)!: clarify Webmention domain terminology Rename ambiguous models, statuses, task modules, fields, and helpers so names reflect source documents, verification, endpoint discovery, and delivery state. Migrate persisted status values and database identifiers without losing existing Webmention data. BREAKING CHANGE: persisted status values and database schema names have changed, and several public Python names have been renamed. --- tests/tasks/test_sender.py | 51 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'tests/tasks/test_sender.py') diff --git a/tests/tasks/test_sender.py b/tests/tasks/test_sender.py index 032b638..9a0430c 100644 --- a/tests/tasks/test_sender.py +++ b/tests/tasks/test_sender.py @@ -14,7 +14,7 @@ import pytest from flask import Flask from webmentions_ssg import db -from webmentions_ssg.models import SentWebmention, SentWebmentionStatus, Source +from webmentions_ssg.models import SentWebmention, SentWebmentionStatus, SourceDocument SOURCE_URL = "https://dennisfink.me/blog/example/" TARGET_URL = "https://example.com/post" @@ -25,7 +25,7 @@ STATUS_URL = "https://example.com/webmention/status/123" def create_sent_webmention( app: Flask, *, - active: bool = True, + linked: bool = True, desired_revision: int = 1, processed_revision: int | None = None, sent_revision: int | None = None, @@ -40,7 +40,7 @@ def create_sent_webmention( now = datetime.now(UTC) with app.app_context(): - source = Source( + source = SourceDocument( path="example/index.html", url=SOURCE_URL, content_hash="0" * 32, @@ -51,14 +51,14 @@ def create_sent_webmention( webmention = SentWebmention( target=TARGET_URL, - active=active, + linked=linked, desired_revision=desired_revision, processed_revision=processed_revision, sent_revision=sent_revision, status=status, failure_reason=failure_reason, - endpoint=endpoint, - response_status=response_status, + webmention_endpoint=endpoint, + endpoint_response_status=response_status, status_url=status_url, attempt_count=attempt_count, next_retry_at=next_retry_at, @@ -145,8 +145,7 @@ def test_attempt_delivery_returns_retryable_outcome( reason="Webmention endpoint returned HTTP 503", endpoint=ENDPOINT_URL, response_status=HTTPStatus.SERVICE_UNAVAILABLE, - terminal=False, - temporary_failure=True, + retryable=True, ) @@ -174,8 +173,8 @@ def test_send_webmention_persists_success( assert webmention.sent_revision == 1 assert webmention.status == SentWebmentionStatus.SENT assert webmention.failure_reason is None - assert webmention.endpoint == ENDPOINT_URL - assert webmention.response_status == HTTPStatus.CREATED + assert webmention.webmention_endpoint == ENDPOINT_URL + assert webmention.endpoint_response_status == HTTPStatus.CREATED assert webmention.status_url == STATUS_URL assert webmention.last_attempted_at is not None assert webmention.last_sent_at is not None @@ -212,10 +211,10 @@ def test_send_webmention_marks_unsupported_target_processed( assert webmention is not None assert webmention.processed_revision == 2 assert webmention.sent_revision == 1 - assert webmention.status == SentWebmentionStatus.UNSUPPORTED + assert webmention.status == SentWebmentionStatus.NO_ENDPOINT assert webmention.failure_reason == "No Webmention endpoint discovered" - assert webmention.endpoint is None - assert webmention.response_status is None + assert webmention.webmention_endpoint is None + assert webmention.endpoint_response_status is None assert webmention.status_url is None assert webmention.last_attempted_at is not None @@ -246,8 +245,8 @@ def test_send_webmention_persists_permanent_failure( assert webmention.sent_revision == 1 assert webmention.status == SentWebmentionStatus.FAILED assert webmention.failure_reason == "Webmention endpoint returned HTTP 400" - assert webmention.endpoint == ENDPOINT_URL - assert webmention.response_status == HTTPStatus.BAD_REQUEST + assert webmention.webmention_endpoint == ENDPOINT_URL + assert webmention.endpoint_response_status == HTTPStatus.BAD_REQUEST assert webmention.status_url is None @@ -277,8 +276,8 @@ def test_send_webmention_persists_temporary_failure_with_backoff( assert webmention.sent_revision == 1 assert webmention.status == SentWebmentionStatus.FAILED assert webmention.failure_reason == "Webmention endpoint returned HTTP 503" - assert webmention.endpoint == ENDPOINT_URL - assert webmention.response_status == HTTPStatus.SERVICE_UNAVAILABLE + assert webmention.webmention_endpoint == ENDPOINT_URL + assert webmention.endpoint_response_status == HTTPStatus.SERVICE_UNAVAILABLE assert webmention.status_url is None assert webmention.attempt_count == 1 assert webmention.next_retry_at is not None @@ -443,8 +442,10 @@ def test_sender_malformed_request_is_terminal( assert webmention.processed_revision == 1 assert webmention.attempt_count == 1 assert webmention.next_retry_at is None - assert webmention.endpoint == (ENDPOINT_URL if stage == "post" else None) - assert webmention.response_status is None + assert webmention.webmention_endpoint == ( + ENDPOINT_URL if stage == "post" else None + ) + assert webmention.endpoint_response_status is None assert webmention.last_attempted_at is not None assert httpx_client.call_count == 1 @@ -554,7 +555,7 @@ def test_send_webmention_lock_is_scoped_to_uuid( first = db.session.get(SentWebmention, first_id) assert first is not None second = SentWebmention( - source_id=first.source_id, target=other_target, desired_revision=1 + source_uuid=first.source_uuid, target=other_target, desired_revision=1 ) db.session.add(second) db.session.commit() @@ -601,7 +602,7 @@ def test_send_webmention_ignores_processed_revision( @pytest.mark.parametrize( - "outcome", ["success", "unsupported", "temporary-failure", "permanent-failure"] + "outcome", ["success", "no_endpoint", "temporary-failure", "permanent-failure"] ) def test_send_webmention_ignores_superseded_attempt( app: Flask, sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch, outcome: str @@ -627,12 +628,12 @@ def test_send_webmention_ignores_superseded_attempt( post.side_effect = post_success - case "unsupported": + case "no_endpoint": - def discover_unsupported(*args, **kwargs) -> None: + def discover_no_endpoint(*args, **kwargs) -> None: supersede_revision() - discover.side_effect = discover_unsupported + discover.side_effect = discover_no_endpoint case "temporary-failure": @@ -708,5 +709,5 @@ def test_send_does_not_persist_unsafe_status_url( mention = db.session.get(SentWebmention, identifier) assert mention is not None assert mention.status == SentWebmentionStatus.SENT - assert mention.response_status == HTTPStatus.CREATED + assert mention.endpoint_response_status == HTTPStatus.CREATED assert mention.status_url == expected -- cgit v1.3.1