summaryrefslogtreecommitdiff
path: root/test/test_graph_http.py
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2021-10-17 21:23:14 +1000
committerGitHub <noreply@github.com>2021-10-17 21:23:14 +1000
commit735ecb99b6def1f0dd7aa480e3a81334ae740a0f (patch)
treece1a92c82c735479ce89ba3258a866d998e286c9 /test/test_graph_http.py
parent9a9ca7c37d936d7ae00134226a8d249d6a97fed7 (diff)
parent49462fddad2bd2ff148134b49241e1c9d5a8e09f (diff)
downloadrdflib-ttl2.tar.gz
Merge branch 'master' into ttl2ttl2
Diffstat (limited to 'test/test_graph_http.py')
-rw-r--r--test/test_graph_http.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/test_graph_http.py b/test/test_graph_http.py
index 1ee8292e..927fdc2e 100644
--- a/test/test_graph_http.py
+++ b/test/test_graph_http.py
@@ -63,7 +63,7 @@ class ContentNegotiationHandler(BaseHTTPRequestHandler):
class TestGraphHTTP(unittest.TestCase):
- def content_negotiation(self) -> None:
+ def test_content_negotiation(self) -> None:
EG = Namespace("http://example.org/")
expected = Graph()
expected.add((EG["a"], EG["b"], EG["c"]))
@@ -77,6 +77,29 @@ class TestGraphHTTP(unittest.TestCase):
graph.parse(url, format=format)
self.assertEqual(expected_triples, GraphHelper.triple_set(graph))
+ def test_source(self) -> None:
+ EG = Namespace("http://example.org/")
+ expected = Graph()
+ expected.add((EG["a"], EG["b"], EG["c"]))
+ expected_triples = GraphHelper.triple_set(expected)
+
+ httpmock = SimpleHTTPMock()
+ with ctx_http_server(httpmock.Handler) as server:
+ (host, port) = server.server_address
+ url = f"http://{host}:{port}/"
+
+ httpmock.do_get_responses.append(
+ MockHTTPResponse(
+ 200,
+ "OK",
+ f"<{EG['a']}> <{EG['b']}> <{EG['c']}>.".encode(),
+ {"Content-Type": ["text/turtle"]},
+ )
+ )
+ graph = Graph()
+ graph.parse(source=url)
+ self.assertEqual(expected_triples, GraphHelper.triple_set(graph))
+
def test_3xx(self) -> None:
EG = Namespace("http://example.com/")
expected = Graph()