aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDennis Fink2026-10-25 22:26:40 +0100
committerDennis Fink2026-10-25 22:26:40 +0100
commitce802830c37565d325ba2ecc060443550abb1955 (patch)
treeb2cdf65353b1eb28d2c8d394b0dcd24461c4db6c /tests
parenta231913ab273f427697f2d27d615b495f6e160bb (diff)
downloadwebmentions-ssg-ce802830c37565d325ba2ecc060443550abb1955.tar.gz
webmentions-ssg-ce802830c37565d325ba2ecc060443550abb1955.zip
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/forms/test_validators.py6
-rw-r--r--tests/tasks/test_notifications.py10
-rw-r--r--tests/tasks/test_receiver.py12
-rw-r--r--tests/tasks/test_scanner.py6
-rw-r--r--tests/tasks/test_sender.py4
5 files changed, 18 insertions, 20 deletions
diff --git a/tests/forms/test_validators.py b/tests/forms/test_validators.py
index c63ee54..6e26039 100644
--- a/tests/forms/test_validators.py
+++ b/tests/forms/test_validators.py
@@ -46,21 +46,21 @@ def test_not_equal_to_rejects_unknown_field() -> None:
def test_allowed_hostname_accepts_configured_hostname(app: Flask) -> None:
- app.config["WEBMENTIONS_SSG_ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
+ app.config["ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
form = URLForm(MultiDict({"url": "https://dennisfink.me/blog/example/"}))
with app.app_context():
AllowedHostname()(form, form.url)
def test_allowed_hostname_rejects_unconfigured_hostname(app: Flask) -> None:
- app.config["WEBMENTIONS_SSG_ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
+ app.config["ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
form = URLForm(MultiDict({"url": "https://example.com/post"}))
with app.app_context(), pytest.raises(ValidationError, match="Invalid input"):
AllowedHostname()(form, form.url)
def test_allowed_hostname_uses_custom_message(app: Flask) -> None:
- app.config["WEBMENTIONS_SSG_ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
+ app.config["ALLOWED_HOSTNAMES"] = ["dennisfink.me"]
form = URLForm(MultiDict({"url": "https://example.com/post"}))
with (
app.app_context(),
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):