From ce802830c37565d325ba2ecc060443550abb1955 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Sun, 25 Oct 2026 22:26:40 +0100 Subject: refactor(core): simplify configuration keys Remove the WEBMENTIONS_SSG prefix from application-specific configuration settings and update validators, tasks, and tests to use the shorter names. --- tests/tasks/test_notifications.py | 10 +++++----- tests/tasks/test_receiver.py | 12 +++++------- tests/tasks/test_scanner.py | 6 +++--- tests/tasks/test_sender.py | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) (limited to 'tests/tasks') diff --git a/tests/tasks/test_notifications.py b/tests/tasks/test_notifications.py index 6069d79..fa6ef79 100644 --- a/tests/tasks/test_notifications.py +++ b/tests/tasks/test_notifications.py @@ -15,7 +15,7 @@ from webmentions_ssg.models import ReceivedWebmention def test_sends_email_for_verified_webmention(app: Flask) -> None: from webmentions_ssg.tasks.notifications import send_webmention_notification - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = "owner@example.com" + app.config["NOTIFICATION_EMAIL"] = "owner@example.com" identifier = uuid.uuid7() with app.app_context(): @@ -43,7 +43,7 @@ def test_sends_email_for_verified_webmention(app: Flask) -> None: def test_skips_unverified_webmentions(app: Flask, status: str) -> None: from webmentions_ssg.tasks.notifications import send_webmention_notification - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = "owner@example.com" + app.config["NOTIFICATION_EMAIL"] = "owner@example.com" identifier = uuid.uuid7() with app.app_context(): @@ -66,7 +66,7 @@ def test_skips_unverified_webmentions(app: Flask, status: str) -> None: def test_skips_when_notifications_disabled(app: Flask) -> None: from webmentions_ssg.tasks.notifications import send_webmention_notification - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = None + app.config["NOTIFICATION_EMAIL"] = None identifier = uuid.uuid7() with app.app_context(): @@ -89,7 +89,7 @@ def test_skips_when_notifications_disabled(app: Flask) -> None: def test_skips_unknown_webmention(app: Flask) -> None: from webmentions_ssg.tasks.notifications import send_webmention_notification - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = "owner@example.com" + app.config["NOTIFICATION_EMAIL"] = "owner@example.com" with app.app_context(): with patch("webmentions_ssg.tasks.notifications.mail.send") as send: @@ -115,7 +115,7 @@ def test_queues_notification_after_verification( ) -> None: from webmentions_ssg.tasks import receiver - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = recipient + app.config["NOTIFICATION_EMAIL"] = recipient identifier = uuid.uuid7() with app.app_context(): diff --git a/tests/tasks/test_receiver.py b/tests/tasks/test_receiver.py index 15289ac..f4ab09f 100644 --- a/tests/tasks/test_receiver.py +++ b/tests/tasks/test_receiver.py @@ -206,9 +206,7 @@ def test_fetch_source_returns_response_and_body( "User-Agent": f"{receiver.APP_NAME}/{receiver.VERSION} ReceivedWebmention", } assert options["follow_redirects"] is True - assert options["max_redirects"] == app.config.get( - "WEBMENTIONS_SSG_MAX_REDIRECTS", 20 - ) + assert options["max_redirects"] == app.config.get("MAX_REDIRECTS", 20) assert options["trust_env"] is False assert options["event_hooks"] == {"request": [receiver.ensure_public_request]} @@ -265,7 +263,7 @@ def test_fetch_source_propagates_network_error( def test_fetch_source_rejects_declared_oversized_body( httpx_client: Mock, app: Flask, receiver: ModuleType ) -> None: - app.config["WEBMENTIONS_SSG_MAX_SOURCE_BYTES"] = 10 + app.config["MAX_SOURCE_BYTES"] = 10 set_stream_response( httpx_client, @@ -288,7 +286,7 @@ def test_fetch_source_rejects_declared_oversized_body( def test_fetch_source_rejects_streamed_oversized_body( httpx_client: Mock, app: Flask, receiver: ModuleType ) -> None: - app.config["WEBMENTIONS_SSG_MAX_SOURCE_BYTES"] = 10 + app.config["MAX_SOURCE_BYTES"] = 10 class BodyStream(httpx.SyncByteStream): def __iter__(self): @@ -471,7 +469,7 @@ def test_verify_webmention_persists_final_state( case _: raise AssertionError(f"Unexpected outcome: {outcome}") - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = "owner@example.com" + app.config["NOTIFICATION_EMAIL"] = "owner@example.com" with patch.object(receiver, "send_webmention_notification") as enqueue: receiver.verify_webmention.call_local(identifier) @@ -502,7 +500,7 @@ def test_verify_webmention_persists_retryable_failure_and_reraises( source_mentions_target.side_effect = exception - app.config["WEBMENTIONS_SSG_NOTIFICATION_EMAIL"] = "owner@example.com" + app.config["NOTIFICATION_EMAIL"] = "owner@example.com" with ( patch.object(receiver, "send_webmention_notification") as enqueue, diff --git a/tests/tasks/test_scanner.py b/tests/tasks/test_scanner.py index 3de5e16..5823e9e 100644 --- a/tests/tasks/test_scanner.py +++ b/tests/tasks/test_scanner.py @@ -91,8 +91,8 @@ def write_post( def configure_scanner(app: Flask, root: Path, *, base_url: str | None = None) -> None: - app.config["WEBMENTIONS_SSG_SOURCE_DIRECTORY"] = str(root) - app.config["WEBMENTIONS_SSG_SOURCE_BASE_URL"] = base_url + app.config["SOURCE_DIRECTORY"] = str(root) + app.config["SOURCE_BASE_URL"] = base_url def test_parse_entry_returns_microformats_entry(scanner_module: ModuleType) -> None: @@ -1646,7 +1646,7 @@ def test_changed_source_url_is_rejected( def test_scan_sources_returns_when_source_directory_is_not_configured( app: Flask, scanner_module: ModuleType ) -> None: - app.config["WEBMENTIONS_SSG_SOURCE_DIRECTORY"] = None + app.config["SOURCE_DIRECTORY"] = None run_scan(app, scanner_module) diff --git a/tests/tasks/test_sender.py b/tests/tasks/test_sender.py index 6e33887..6a9afc1 100644 --- a/tests/tasks/test_sender.py +++ b/tests/tasks/test_sender.py @@ -988,7 +988,7 @@ def test_endpoint_from_html_ignores_elements_without_rel_and_non_string_href( def test_read_target_body_rejects_declared_oversized_body( app: Flask, sender_module: ModuleType ) -> None: - app.config["WEBMENTIONS_SSG_MAX_TARGET_BYTES"] = 10 + app.config["MAX_TARGET_BYTES"] = 10 response = httpx.Response(200, headers={"Content-Length": "11"}, content=b"x" * 11) @@ -1017,7 +1017,7 @@ def test_read_target_body_ignores_invalid_content_length( def test_read_target_body_rejects_streamed_oversized_body( app: Flask, sender_module: ModuleType ) -> None: - app.config["WEBMENTIONS_SSG_MAX_TARGET_BYTES"] = 10 + app.config["MAX_TARGET_BYTES"] = 10 class BodyStream(httpx.SyncByteStream): def __iter__(self): -- cgit v1.3.1