Mercurial > code > home > repos > rdferry
comparison 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 |
comparison
equal
deleted
inserted
replaced
9:b72f4ba1345d | 10:52e1bb1532f2 |
---|---|
1 from pathlib import Path | |
2 | |
3 import pytest | |
4 | |
5 from examples._run_server_child import RunHttpServerChildProcess | |
6 | |
7 server_path = Path('examples/serve_inline_graph.py') | |
8 | |
9 | |
10 @pytest.mark.asyncio | |
11 async def test_server_returns_n3(): | |
12 async with RunHttpServerChildProcess(server_path) as http_server: | |
13 response = await http_server.get('http://localhost:8005/g1') | |
14 assert (await response.text() | |
15 ) == '''@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
16 | |
17 <http://example.com/process> { | |
18 <http://example.com/greeting> rdfs:label "hello world" . | |
19 } | |
20 | |
21 ''' | |
22 | |
23 | |
24 @pytest.mark.asyncio | |
25 async def test_server_returns_trig(): | |
26 async with RunHttpServerChildProcess(server_path) as http_server: | |
27 response = await http_server.get( | |
28 'http://localhost:8005/g1', | |
29 headers={'accept': "application/n-quads"}) | |
30 assert ( | |
31 await response.text() | |
32 ) == '''<http://example.com/greeting> <http://www.w3.org/2000/01/rdf-schema#label> "hello world" <http://example.com/process> . | |
33 | |
34 ''' | |
35 | |
36 | |
37 # @pytest.mark.asyncio | |
38 # async def test_server_returns_events(): | |
39 # async with RunHttpServerChildProcess(server_path) as http_server: | |
40 # response = await http_server.get('http://localhost:8005/g1/events') | |
41 # assert response.headers['content-type'] == 'x-sse-todo' | |
42 # assert (await response.text()) == 'clear event then add-patch event' |