summaryrefslogtreecommitdiff
path: root/test/test_graph/test_graph_http.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_graph/test_graph_http.py')
-rw-r--r--test/test_graph/test_graph_http.py43
1 files changed, 39 insertions, 4 deletions
diff --git a/test/test_graph/test_graph_http.py b/test/test_graph/test_graph_http.py
index 762e3d5b..97c64c3a 100644
--- a/test/test_graph/test_graph_http.py
+++ b/test/test_graph/test_graph_http.py
@@ -1,14 +1,20 @@
+import logging
import re
from http.server import BaseHTTPRequestHandler
from test.data import TEST_DATA_DIR
from test.utils import GraphHelper
from test.utils.graph import cached_graph
-from test.utils.http import ctx_http_handler
+from test.utils.http import (
+ MOCK_HTTP_REQUEST_WILDCARD,
+ MockHTTPRequest,
+ ctx_http_handler,
+)
from test.utils.httpservermock import (
MethodName,
MockHTTPResponse,
ServedBaseHTTPServerMock,
)
+from test.utils.wildcard import URL_PARSE_RESULT_WILDCARD
from urllib.error import HTTPError
import pytest
@@ -235,7 +241,34 @@ class TestGraphHTTP:
assert raised.value.code == 500
-def test_iri_source(function_httpmock: ServedBaseHTTPServerMock) -> None:
+@pytest.mark.parametrize(
+ ["url_suffix", "expected_request"],
+ [
+ (
+ "/resource/Almería",
+ MOCK_HTTP_REQUEST_WILDCARD._replace(
+ path="/resource/Almer%C3%ADa",
+ parsed_path=URL_PARSE_RESULT_WILDCARD._replace(
+ path="/resource/Almer%C3%ADa"
+ ),
+ ),
+ ),
+ (
+ "/resource/Almería?foo=bar",
+ MOCK_HTTP_REQUEST_WILDCARD._replace(
+ parsed_path=URL_PARSE_RESULT_WILDCARD._replace(
+ path="/resource/Almer%C3%ADa"
+ ),
+ path_query={"foo": ["bar"]},
+ ),
+ ),
+ ],
+)
+def test_iri_source(
+ url_suffix: str,
+ expected_request: MockHTTPRequest,
+ function_httpmock: ServedBaseHTTPServerMock,
+) -> None:
diverse_triples_path = TEST_DATA_DIR / "variants/diverse_triples.ttl"
function_httpmock.responses[MethodName.GET].append(
@@ -247,9 +280,11 @@ def test_iri_source(function_httpmock: ServedBaseHTTPServerMock) -> None:
)
)
g = Graph()
- g.parse(f"{function_httpmock.url}/resource/Almería")
+ g.parse(f"{function_httpmock.url}{url_suffix}")
assert function_httpmock.call_count == 1
GraphHelper.assert_triple_sets_equals(cached_graph((diverse_triples_path,)), g)
+ assert len(g) > 1
req = function_httpmock.requests[MethodName.GET].pop(0)
- assert req.path == "/resource/Almer%C3%ADa"
+ logging.debug("req = %s", req)
+ assert expected_request == req