(
test_client_factory: TestClientFactory,
)
| 132 | |
| 133 | |
| 134 | def test_websocket_endpoint_on_receive_text( |
| 135 | test_client_factory: TestClientFactory, |
| 136 | ) -> None: |
| 137 | class WebSocketApp(WebSocketEndpoint): |
| 138 | encoding = class="st">"text" |
| 139 | |
| 140 | async def on_receive(self, websocket: WebSocket, data: str) -> None: |
| 141 | await websocket.send_text(fclass="st">"Message text was: {data}") |
| 142 | |
| 143 | client = test_client_factory(WebSocketApp) |
| 144 | with client.websocket_connect(class="st">"/ws") as websocket: |
| 145 | websocket.send_text(class="st">"Hello, world!") |
| 146 | _text = websocket.receive_text() |
| 147 | assert _text == class="st">"Message text was: Hello, world!" |
| 148 | |
| 149 | with pytest.raises(RuntimeError): |
| 150 | with client.websocket_connect(class="st">"/ws") as websocket: |
| 151 | websocket.send_bytes(bclass="st">"Hello world") |
| 152 | |
| 153 | |
| 154 | def test_websocket_endpoint_on_default(test_client_factory: TestClientFactory) -> None: |
nothing calls this directly
no test coverage detected