Mercurial > code > home > repos > rdferry
diff examples/serve_inline_graph_test.py @ 10:52e1bb1532f2
serve_inline_graph
author | drewp@bigasterisk.com |
---|---|
date | Sat, 16 Mar 2024 16:02:23 -0700 |
parents | |
children | 0bc06da6bf74 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/serve_inline_graph_test.py Sat Mar 16 16:02:23 2024 -0700 @@ -0,0 +1,42 @@ +from pathlib import Path + +import pytest + +from examples._run_server_child import RunHttpServerChildProcess + +server_path = Path('examples/serve_inline_graph.py') + + +@pytest.mark.asyncio +async def test_server_returns_n3(): + async with RunHttpServerChildProcess(server_path) as http_server: + response = await http_server.get('http://localhost:8005/g1') + assert (await response.text() + ) == '''@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . + +<http://example.com/process> { + <http://example.com/greeting> rdfs:label "hello world" . +} + +''' + + +@pytest.mark.asyncio +async def test_server_returns_trig(): + async with RunHttpServerChildProcess(server_path) as http_server: + response = await http_server.get( + 'http://localhost:8005/g1', + headers={'accept': "application/n-quads"}) + assert ( + await response.text() + ) == '''<http://example.com/greeting> <http://www.w3.org/2000/01/rdf-schema#label> "hello world" <http://example.com/process> . + +''' + + +# @pytest.mark.asyncio +# async def test_server_returns_events(): +# async with RunHttpServerChildProcess(server_path) as http_server: +# response = await http_server.get('http://localhost:8005/g1/events') +# assert response.headers['content-type'] == 'x-sse-todo' +# assert (await response.text()) == 'clear event then add-patch event'