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

Method test_accept_response

tests/test_server.py:265–285  ·  view source on GitHub ↗

accept() creates a successful opening handshake response.

(self, _formatdate)

Source from the content-addressed store, hash-verified

263
264 @patch("email.utils.formatdate", return_value=DATE)
265 def test_accept_response(self, _formatdate):
266 """accept() creates a successful opening handshake response."""
267 server = ServerProtocol()
268 request = make_request()
269 response = server.accept(request)
270
271 self.assertIsInstance(response, Response)
272 self.assertEqual(response.status_code, 101)
273 self.assertEqual(response.reason_phrase, "Switching Protocols")
274 self.assertEqual(
275 response.headers,
276 Headers(
277 {
278 "Date": DATE,
279 "Upgrade": "websocket",
280 "Connection": "Upgrade",
281 "Sec-WebSocket-Accept": ACCEPT,
282 }
283 ),
284 )
285 self.assertEqual(response.body, b"")
286
287 @patch("email.utils.formatdate", return_value=DATE)
288 def test_reject_response(self, _formatdate):

Callers

nothing calls this directly

Calls 4

acceptMethod · 0.95
HeadersClass · 0.90
ServerProtocolClass · 0.85
make_requestFunction · 0.85

Tested by

no test coverage detected