MCPcopy Create free account
hub / github.com/encode/starlette / test_websocket_endpoint_on_default

Function test_websocket_endpoint_on_default

tests/test_endpoints.py:165–176  ·  view source on GitHub ↗
(test_client_factory: TestClientFactory)

Source from the content-addressed store, hash-verified

163
164
165def 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
179def test_websocket_endpoint_on_default_with_empty_text(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80
send_textMethod · 0.45
receive_textMethod · 0.45

Tested by

no test coverage detected