diff options
| author | Dennis Fink | 2026-08-15 20:54:53 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-08-15 20:54:53 +0200 |
| commit | e0f65d7ff582b32f1c7b5508bba8cda807aaae5f (patch) | |
| tree | 6693b9fc259bf642e0392b4d8920fbca7ffd6dda /tests/test_forms.py | |
| parent | b3e12b975064f0873bdb4d2834cae75925387d6b (diff) | |
| download | webmentions-ssg-e0f65d7ff582b32f1c7b5508bba8cda807aaae5f.tar.gz webmentions-ssg-e0f65d7ff582b32f1c7b5508bba8cda807aaae5f.zip | |
feat(sender): add outgoing Webmention pipeline
Scan generated h-entry documents for Webmention targets and track source
revisions and delivery state in the database.
Discover target endpoints, send Webmentions asynchronously, and reconcile
updated, removed, restored, and deleted sources across scans.
Add authenticated views for inspecting sent Webmentions and make the scanner
schedule configurable.
Diffstat (limited to '')
| -rw-r--r-- | tests/test_forms.py | 80 |
1 files changed, 16 insertions, 64 deletions
diff --git a/tests/test_forms.py b/tests/test_forms.py index 417c655..73c6ffc 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -10,83 +10,54 @@ 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, -) +@patch("webmentions_ssg.forms.validators.is_public_url", new=lambda url: True) @pytest.mark.parametrize( - ( - "form_data", - "invalid_field", - "expected_error", - ), + ("form_data", "invalid_field", "expected_error"), [ pytest.param( - { - "target": VALID_TARGET, - }, + {"target": VALID_TARGET}, "source", "This field is required.", id="source-required", ), pytest.param( - { - "source": "not a URL", - "target": VALID_TARGET, - }, + {"source": "not a URL", "target": VALID_TARGET}, "source", "Invalid URL.", id="source-url", ), pytest.param( - { - "source": "ftp://source.example/post", - "target": VALID_TARGET, - }, + {"source": "ftp://source.example/post", "target": VALID_TARGET}, "source", "source must begin with http or https", id="source-scheme", ), pytest.param( - { - "source": VALID_TARGET, - "target": VALID_TARGET, - }, + {"source": VALID_TARGET, "target": VALID_TARGET}, "source", None, id="source-not-equal-to-target", ), pytest.param( - { - "source": VALID_SOURCE, - }, + {"source": VALID_SOURCE}, "target", "This field is required.", id="target-required", ), pytest.param( - { - "source": VALID_SOURCE, - "target": "not a URL", - }, + {"source": VALID_SOURCE, "target": "not a URL"}, "target", "Invalid URL.", id="target-url", ), pytest.param( - { - "source": VALID_SOURCE, - "target": "ftp://dennisfink.me/blog/example/", - }, + {"source": VALID_SOURCE, "target": "ftp://dennisfink.me/blog/example/"}, "target", "target must begin with http or https", id="target-scheme", ), pytest.param( - { - "source": VALID_SOURCE, - "target": "https://example.com/post", - }, + {"source": VALID_SOURCE, "target": "https://example.com/post"}, "target", None, id="target-allowed-hostname", @@ -99,14 +70,8 @@ def test_endpoint_form_rejects_invalid_data( invalid_field: str, expected_error: str | None, ) -> None: - with app.test_request_context( - "/endpoint", - method="POST", - ): - form = EndpointForm( - formdata=MultiDict(form_data), - meta={"csrf": False}, - ) + with app.test_request_context("/endpoint", method="POST"): + form = EndpointForm(formdata=MultiDict(form_data), meta={"csrf": False}) assert not form.validate() assert invalid_field in form.errors @@ -115,24 +80,11 @@ 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, -) -> None: - with app.test_request_context( - "/endpoint", - method="POST", - ): +@patch("webmentions_ssg.forms.validators.is_public_url", new=lambda url: True) +def test_endpoint_form_accepts_valid_data(app: Flask) -> None: + with app.test_request_context("/endpoint", method="POST"): form = EndpointForm( - formdata=MultiDict( - { - "source": VALID_SOURCE, - "target": VALID_TARGET, - } - ), + formdata=MultiDict({"source": VALID_SOURCE, "target": VALID_TARGET}), meta={"csrf": False}, ) |
