aboutsummaryrefslogtreecommitdiff
path: root/tests/test_forms.py
diff options
context:
space:
mode:
authorDennis Fink2026-08-10 20:00:28 +0200
committerDennis Fink2026-08-10 20:00:28 +0200
commit5b39f70aa14cac635b6084170e9d0bd3f548b911 (patch)
treedaef3fddff0679efb23a42a58743e7c2a3597213 /tests/test_forms.py
parent8350bef3e3baea6042ed3780a054cc65707e9f8d (diff)
downloadwebmentions-ssg-5b39f70aa14cac635b6084170e9d0bd3f548b911.tar.gz
webmentions-ssg-5b39f70aa14cac635b6084170e9d0bd3f548b911.zip
test: simplify mocks and localize test fixtures
Replace shared HTTPX and DNS fixtures with targeted unittest.mock patches close to the tests that need them. Keep conftest focused on application and client setup, while moving receiver-specific helpers into the receiver test module.
Diffstat (limited to '')
-rw-r--r--tests/test_forms.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py
index 2d5fc01..417c655 100644
--- a/tests/test_forms.py
+++ b/tests/test_forms.py
@@ -1,3 +1,5 @@
+from unittest.mock import patch
+
import pytest
from flask import Flask
from werkzeug.datastructures import MultiDict
@@ -8,6 +10,10 @@ VALID_SOURCE = "https://source.example/post"
VALID_TARGET = "https://dennisfink.me/blog/example/"
+@patch(
+ "webmentions_ssg.forms.validators.ensure_public_url",
+ new=lambda url: None,
+)
@pytest.mark.parametrize(
(
"form_data",
@@ -89,7 +95,6 @@ VALID_TARGET = "https://dennisfink.me/blog/example/"
)
def test_endpoint_form_rejects_invalid_data(
app: Flask,
- public_dns: None,
form_data: dict[str, str],
invalid_field: str,
expected_error: str | None,
@@ -110,9 +115,12 @@ def test_endpoint_form_rejects_invalid_data(
assert expected_error in form.errors[invalid_field]
+@patch(
+ "webmentions_ssg.forms.validators.ensure_public_url",
+ new=lambda url: None,
+)
def test_endpoint_form_accepts_valid_data(
app: Flask,
- public_dns: None,
) -> None:
with app.test_request_context(
"/endpoint",