comparison examples/serve_inline_graph_test.py @ 11:0bc06da6bf74

start ferry1 patch protocol
author drewp@bigasterisk.com
date Mon, 18 Mar 2024 16:42:21 -0700
parents 52e1bb1532f2
children ba73d8ba81dc
comparison
equal deleted inserted replaced
10:52e1bb1532f2 11:0bc06da6bf74
1 from pathlib import Path 1 from pathlib import Path
2 2 import logging
3 import pytest 3 import pytest
4 4
5 from examples._run_server_child import RunHttpServerChildProcess 5 from examples._run_server_child import RunHttpServerChildProcess, assert_event_stream_starts_with
6 6
7 log = logging.getLogger('test')
8 logging.basicConfig(level=logging.INFO)
7 server_path = Path('examples/serve_inline_graph.py') 9 server_path = Path('examples/serve_inline_graph.py')
8 10
9 11
10 @pytest.mark.asyncio 12 @pytest.mark.asyncio
11 async def test_server_returns_n3(): 13 async def test_server_returns_n3():
32 ) == '''<http://example.com/greeting> <http://www.w3.org/2000/01/rdf-schema#label> "hello world" <http://example.com/process> . 34 ) == '''<http://example.com/greeting> <http://www.w3.org/2000/01/rdf-schema#label> "hello world" <http://example.com/process> .
33 35
34 ''' 36 '''
35 37
36 38
37 # @pytest.mark.asyncio 39 @pytest.mark.asyncio
38 # async def test_server_returns_events(): 40 async def test_server_returns_startup_events():
39 # async with RunHttpServerChildProcess(server_path) as http_server: 41 async with RunHttpServerChildProcess(server_path) as http_server:
40 # response = await http_server.get('http://localhost:8005/g1/events') 42 await assert_event_stream_starts_with(
41 # assert response.headers['content-type'] == 'x-sse-todo' 43 http_server,
42 # assert (await response.text()) == 'clear event then add-patch event' 44 'http://localhost:8005/g1/events',
45 expected_events=[
46 ('clear', 'ferry1'),
47 ('patch',
48 '-\n+\n["http://example.com/greeting", "http://www.w3.org/2000/01/rdf-schema#label", "hello world", "http://www.w3.org/2001/XMLSchema#string", "", "http://example.com/process"]'
49 ),
50 ])