File: test_chat.py

package info (click to toggle)
quart 0.20.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,888 kB
  • sloc: python: 8,644; makefile: 42; sh: 17; sql: 6
file content (20 lines) | stat: -rw-r--r-- 558 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import asyncio

from chat import app

from quart.testing.connections import (
    TestWebsocketConnection as _TestWebsocketConnection,
)


async def _receive(test_websocket: _TestWebsocketConnection) -> str:
    return await test_websocket.receive()


async def test_websocket() -> None:
    test_client = app.test_client()
    async with test_client.websocket("/ws") as test_websocket:
        task = asyncio.ensure_future(_receive(test_websocket))
        await test_websocket.send("message")
        result = await task
        assert result == "message"