(test_client_factory: TestClientFactory)
| 163 | |
| 164 | |
| 165 | def test_websocket_endpoint_on_default(test_client_factory: TestClientFactory) -> None: |
| 166 | class WebSocketApp(WebSocketEndpoint): |
| 167 | encoding = None |
| 168 | |
| 169 | async def on_receive(self, websocket: WebSocket, data: str) -> None: |
| 170 | await websocket.send_text(f"Message text was: {data}") |
| 171 | |
| 172 | client = test_client_factory(WebSocketApp) |
| 173 | with client.websocket_connect("/ws") as websocket: |
| 174 | websocket.send_text("Hello, world!") |
| 175 | _text = websocket.receive_text() |
| 176 | assert _text == "Message text was: Hello, world!" |
| 177 | |
| 178 | |
| 179 | def test_websocket_endpoint_on_default_with_empty_text(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected