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

Function test_websocket_query_params

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

Source from the content-addressed store, hash-verified

62
63
64def test_websocket_query_params(test_client_factory: TestClientFactory) -> None:
65 async def app(scope: Scope, receive: Receive, send: Send) -> None:
66 websocket = WebSocket(scope, receive=receive, send=send)
67 query_params = dict(websocket.query_params)
68 await websocket.accept()
69 await websocket.send_json({"params": query_params})
70 await websocket.close()
71
72 client = test_client_factory(app)
73 with client.websocket_connect("/?a=abc&b=456") as websocket:
74 data = websocket.receive_json()
75 assert data == {"params": {"a": "abc", "b": "456"}}
76
77
78@pytest.mark.skipif(

Callers

nothing calls this directly

Calls 3

receive_jsonMethod · 0.95
test_client_factoryFunction · 0.85
websocket_connectMethod · 0.80

Tested by

no test coverage detected