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

Method test_reject_response

tests/test_server.py:288–307  ·  view source on GitHub ↗

reject() creates a failed opening handshake response.

(self, _formatdate)

Source from the content-addressed store, hash-verified

286
287 @patch("email.utils.formatdate", return_value=DATE)
288 def test_reject_response(self, _formatdate):
289 """reject() creates a failed opening handshake response."""
290 server = ServerProtocol()
291 response = server.reject(http.HTTPStatus.NOT_FOUND, "Sorry folks.\n")
292
293 self.assertIsInstance(response, Response)
294 self.assertEqual(response.status_code, 404)
295 self.assertEqual(response.reason_phrase, "Not Found")
296 self.assertEqual(
297 response.headers,
298 Headers(
299 {
300 "Date": DATE,
301 "Connection": "close",
302 "Content-Length": "13",
303 "Content-Type": "text/plain; charset=utf-8",
304 }
305 ),
306 )
307 self.assertEqual(response.body, b"Sorry folks.\n")
308
309 def test_reject_response_supports_int_status(self):
310 """reject() accepts an integer status code instead of an HTTPStatus."""

Callers

nothing calls this directly

Calls 3

rejectMethod · 0.95
HeadersClass · 0.90
ServerProtocolClass · 0.85

Tested by

no test coverage detected