aboutsummaryrefslogtreecommitdiff
path: root/tests/tasks/test_discovery.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/tasks/test_discovery.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/tasks/test_discovery.py b/tests/tasks/test_discovery.py
index ab621e7..4616a53 100644
--- a/tests/tasks/test_discovery.py
+++ b/tests/tasks/test_discovery.py
@@ -58,19 +58,19 @@ def sender_module(app: Flask) -> ModuleType:
),
),
)
-def test_parse_link_value(
+def test_parse_link_header_value(
sender_module: ModuleType, value: str, expected: tuple[str, set[str]]
) -> None:
- assert sender_module.parse_link_value(value) == expected
+ assert sender_module.parse_link_header_value(value) == expected
@pytest.mark.parametrize(
"value", ("", "https://example.com/webmention", "<https://example.com/webmention")
)
-def test_parse_link_value_rejects_malformed_value(
+def test_parse_link_header_value_rejects_malformed_value(
sender_module: ModuleType, value: str
) -> None:
- assert sender_module.parse_link_value(value) is None
+ assert sender_module.parse_link_header_value(value) is None
@pytest.mark.parametrize(
@@ -583,7 +583,7 @@ def test_discovery_does_not_suppress_unexpected_head_error(
def request_hook(request: httpx.Request) -> None:
if request.method == "HEAD":
- raise sender_module.TemporarySenderError("HEAD DNS lookup failed")
+ raise sender_module.RetryableDeliveryError("HEAD DNS lookup failed")
def handler(request: httpx.Request) -> httpx.Response:
methods.append(request.method)
@@ -598,7 +598,7 @@ def test_discovery_does_not_suppress_unexpected_head_error(
event_hooks={"request": [request_hook]},
) as client,
pytest.raises(
- sender_module.TemporarySenderError, match="HEAD DNS lookup failed"
+ sender_module.RetryableDeliveryError, match="HEAD DNS lookup failed"
),
):
sender_module.discover_webmention_endpoint(client, TARGET_URL)
@@ -703,20 +703,20 @@ def test_discovery_returns_none_when_all_html_candidates_are_invalid(
assert endpoint is None
-def test_resolve_endpoint_rejects_invalid_url(
+def test_resolve_endpoint_url_rejects_invalid_url(
sender_module: ModuleType, monkeypatch: pytest.MonkeyPatch
) -> None:
is_http_url = Mock(return_value=False)
monkeypatch.setattr(discovery, "is_http_url", is_http_url)
response = httpx.Response(HTTPStatus.OK, request=httpx.Request("GET", TARGET_URL))
with pytest.raises(
- sender_module.PermanentSenderError, match="Invalid Webmention endpoint"
+ sender_module.PermanentDeliveryError, match="Invalid Webmention endpoint"
):
- sender_module.resolve_endpoint(response, "/webmention")
+ sender_module.resolve_endpoint_url(response, "/webmention")
is_http_url.assert_called_once_with(ENDPOINT_URL)
-def test_endpoint_from_headers_ignores_malformed_link(
+def test_find_endpoint_in_headers_ignores_malformed_link(
sender_module: ModuleType,
) -> None:
response = httpx.Response(
@@ -724,36 +724,36 @@ def test_endpoint_from_headers_ignores_malformed_link(
headers=[("Link", "not-a-link"), ("Link", "</webmention>; rel=webmention")],
request=httpx.Request("GET", TARGET_URL),
)
- assert sender_module.endpoint_from_headers(response) == ENDPOINT_URL
+ assert sender_module.find_endpoint_in_headers(response) == ENDPOINT_URL
-def test_endpoint_from_html_accepts_string_rel(sender_module: ModuleType) -> None:
+def test_find_endpoint_in_html_accepts_string_rel(sender_module: ModuleType) -> None:
response = httpx.Response(HTTPStatus.OK, request=httpx.Request("GET", TARGET_URL))
body = b'<link rel="webmention alternate" href="/webmention">'
- assert sender_module.endpoint_from_html(response, body) == ENDPOINT_URL
+ assert sender_module.find_endpoint_in_html(response, body) == ENDPOINT_URL
-def test_endpoint_from_html_accepts_uppercase_rel(sender_module: ModuleType) -> None:
+def test_find_endpoint_in_html_accepts_uppercase_rel(sender_module: ModuleType) -> None:
response = httpx.Response(HTTPStatus.OK, request=httpx.Request("GET", TARGET_URL))
body = b'<LINK REL="ALTERNATE WEBMENTION" HREF="/webmention">'
- assert sender_module.endpoint_from_html(response, body) == ENDPOINT_URL
+ assert sender_module.find_endpoint_in_html(response, body) == ENDPOINT_URL
-def test_endpoint_from_html_ignores_elements_without_matching_rel_or_href(
+def test_find_endpoint_in_html_ignores_elements_without_matching_rel_or_href(
sender_module: ModuleType,
) -> None:
response = httpx.Response(HTTPStatus.OK, request=httpx.Request("GET", TARGET_URL))
body = b'<link href="/ignored"><a rel="webmention">No endpoint</a>'
- assert sender_module.endpoint_from_html(response, body) is None
+ assert sender_module.find_endpoint_in_html(response, body) is None
def test_read_target_body_rejects_declared_oversized_body(
app: Flask, sender_module: ModuleType
) -> None:
- app.config["MAX_TARGET_BYTES"] = 10
+ app.config["MAX_DISCOVERY_TARGET_BYTES"] = 10
response = httpx.Response(
HTTPStatus.OK, headers={"Content-Length": "11"}, content=b"x" * 11
@@ -762,7 +762,7 @@ def test_read_target_body_rejects_declared_oversized_body(
with (
app.app_context(),
pytest.raises(
- sender_module.PermanentSenderError, match="Target document is too large"
+ sender_module.PermanentDeliveryError, match="Target document is too large"
),
):
sender_module.read_target_body(response)
@@ -800,7 +800,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["MAX_TARGET_BYTES"] = 10
+ app.config["MAX_DISCOVERY_TARGET_BYTES"] = 10
class BodyStream(httpx.SyncByteStream):
def __iter__(self):
@@ -812,7 +812,7 @@ def test_read_target_body_rejects_streamed_oversized_body(
with (
app.app_context(),
pytest.raises(
- sender_module.PermanentSenderError, match="Target document is too large"
+ sender_module.PermanentDeliveryError, match="Target document is too large"
),
):
sender_module.read_target_body(response)
@@ -849,9 +849,9 @@ def test_discovery_uses_link_header_from_get(
("status_code", "exception_name"),
[
pytest.param(
- HTTPStatus.SERVICE_UNAVAILABLE, "TemporarySenderError", id="temporary"
+ HTTPStatus.SERVICE_UNAVAILABLE, "RetryableDeliveryError", id="temporary"
),
- pytest.param(HTTPStatus.NOT_FOUND, "PermanentSenderError", id="permanent"),
+ pytest.param(HTTPStatus.NOT_FOUND, "PermanentDeliveryError", id="permanent"),
],
)
def test_discovery_maps_get_status_to_exception(