MCPcopy Index your code
hub / github.com/python-websockets/websockets / test_send_request

Method test_send_request

tests/test_client.py:40–59  ·  view source on GitHub ↗

Client sends a handshake request.

(self, _generate_key)

Source from the content-addressed store, hash-verified

38 """Test basic opening handshake scenarios."""
39
40 def test_send_request(self, _generate_key):
41 """Client sends a handshake request."""
42 client = ClientProtocol(URI)
43 request = client.connect()
44 client.send_request(request)
45
46 self.assertEqual(
47 client.data_to_send(),
48 [
49 f"GET /test HTTP/1.1\r\n"
50 f"Host: example.com\r\n"
51 f"Upgrade: websocket\r\n"
52 f"Connection: Upgrade\r\n"
53 f"Sec-WebSocket-Key: {KEY}\r\n"
54 f"Sec-WebSocket-Version: 13\r\n"
55 f"\r\n".encode()
56 ],
57 )
58 self.assertFalse(client.close_expected())
59 self.assertEqual(client.state, CONNECTING)
60
61 def test_receive_successful_response(self, _generate_key):
62 """Client receives a successful handshake response."""

Callers

nothing calls this directly

Calls 6

connectMethod · 0.95
send_requestMethod · 0.95
ClientProtocolClass · 0.85
data_to_sendMethod · 0.80
close_expectedMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected