MCPcopy
hub / github.com/encode/starlette / test_websocket_endpoint_on_connect

Function test_websocket_endpoint_on_connect

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

Source from the content-addressed store, hash-verified

65
66
67def test_websocket_endpoint_on_connect(test_client_factory: TestClientFactory) -> None:
68 class WebSocketApp(WebSocketEndpoint):
69 async def on_connect(self, websocket: WebSocket) -> None:
70 assert websocket["subprotocols"] == ["soap", "wamp"]
71 await websocket.accept(subprotocol="wamp")
72
73 client = test_client_factory(WebSocketApp)
74 with client.websocket_connect("/ws", subprotocols=["soap", "wamp"]) as websocket:
75 assert websocket.accepted_subprotocol == "wamp"
76
77
78def test_websocket_endpoint_on_receive_bytes(

Callers

nothing calls this directly

Calls 2

test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected