Skip to content

Commit

Permalink
Update test for sse.send() with event id
Browse files Browse the repository at this point in the history
tests/test_sse.py:
- add test cases for sending event with custom event type and id, and just id.
  • Loading branch information
Hamsanger committed Mar 10, 2024
1 parent 20bbe1c commit 67c4a0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def test_sse(self):
async def handle_sse(request, sse):
await sse.send('foo')
await sse.send('bar', event='test')
await sse.send('bar', event='test', event_id='id42')
await sse.send('bar', event_id='id42')
await sse.send({'foo': 'bar'})
await sse.send([42, 'foo', 'bar'])
await sse.send(ValueError('foo'))
Expand All @@ -34,6 +36,8 @@ async def handle_sse(request, sse):
self.assertEqual(response.headers['Content-Type'], 'text/event-stream')
self.assertEqual(response.text, ('data: foo\n\n'
'event: test\ndata: bar\n\n'
'event: test\nid: id42\ndata: bar\n\n'
'id: id42\ndata: bar\n\n'
'data: {"foo": "bar"}\n\n'
'data: [42, "foo", "bar"]\n\n'
'data: foo\n\n'
Expand Down

0 comments on commit 67c4a0d

Please sign in to comment.