MCPcopy Create free account
hub / github.com/python-websockets/websockets / test_receive_failed_response

Method test_receive_failed_response

tests/test_client.py:79–96  ·  view source on GitHub ↗

Client receives a failed handshake response.

(self, _generate_key)

Source from the content-addressed store, hash-verified

77 self.assertEqual(client.state, OPEN)
78
79 def test_receive_failed_response(self, _generate_key):
80 """Client receives a failed handshake response."""
81 client = ClientProtocol(URI)
82 client.receive_data(
83 (
84 f"HTTP/1.1 404 Not Found\r\n"
85 f"Date: {DATE}\r\n"
86 f"Content-Length: 13\r\n"
87 f"Content-Type: text/plain; charset=utf-8\r\n"
88 f"Connection: close\r\n"
89 f"\r\n"
90 f"Sorry folks.\n"
91 ).encode(),
92 )
93
94 self.assertEqual(client.data_to_send(), [b""])
95 self.assertTrue(client.close_expected())
96 self.assertEqual(client.state, CONNECTING)
97
98
99class RequestTests(unittest.TestCase):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected