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

Method test_receive_request

tests/test_server.py:51–68  ·  view source on GitHub ↗

Server receives a handshake request.

(self, _formatdate)

Source from the content-addressed store, hash-verified

49 """Test basic opening handshake scenarios."""
50
51 def test_receive_request(self, _formatdate):
52 """Server receives a handshake request."""
53 server = ServerProtocol()
54 server.receive_data(
55 (
56 f"GET /test HTTP/1.1\r\n"
57 f"Host: example.com\r\n"
58 f"Upgrade: websocket\r\n"
59 f"Connection: Upgrade\r\n"
60 f"Sec-WebSocket-Key: {KEY}\r\n"
61 f"Sec-WebSocket-Version: 13\r\n"
62 f"\r\n"
63 ).encode(),
64 )
65
66 self.assertEqual(server.data_to_send(), [])
67 self.assertFalse(server.close_expected())
68 self.assertEqual(server.state, CONNECTING)
69
70 def test_accept_and_send_successful_response(self, _formatdate):
71 """Server accepts a handshake request and sends a successful response."""

Callers

nothing calls this directly

Calls 5

ServerProtocolClass · 0.85
receive_dataMethod · 0.80
data_to_sendMethod · 0.80
close_expectedMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected