MCPcopy
hub / github.com/urllib3/urllib3 / test_request_GET

Method test_request_GET

test/test_http2_connection.py:241–272  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

239 conn.send(1)
240
241 def test_request_GET(self) -> None:
242 conn = HTTP2Connection("example.com")
243 conn.sock = mock.MagicMock(
244 sendall=mock.Mock(return_value=None),
245 )
246 sendall = conn.sock.sendall
247 data_to_send = conn._h2_conn._obj.data_to_send = mock.Mock(return_value=b"foo") # type: ignore[method-assign]
248 send_headers = conn._h2_conn._obj.send_headers = mock.Mock(return_value=None) # type: ignore[method-assign]
249 conn._h2_conn._obj.send_data = mock.Mock(return_value=None) # type: ignore[method-assign]
250 conn._h2_conn._obj.get_next_available_stream_id = mock.Mock(return_value=1) # type: ignore[method-assign]
251 close_connection = conn._h2_conn._obj.close_connection = mock.Mock( # type: ignore[method-assign]
252 return_value=None
253 )
254
255 conn.request("GET", "/")
256 conn.close()
257
258 data_to_send.assert_called_with()
259 sendall.assert_called_with(b"foo")
260 send_headers.assert_called_with(
261 stream_id=1,
262 headers=[
263 (b":scheme", b"https"),
264 (b":method", b"GET"),
265 (b":authority", b"example.com:443"),
266 (b":path", b"/"),
267 (b"user-agent", _get_default_user_agent().encode()),
268 ],
269 end_stream=True,
270 )
271
272 close_connection.assert_called_with()
273
274 def test_request_POST(self) -> None:
275 conn = HTTP2Connection("example.com")

Callers

nothing calls this directly

Calls 4

requestMethod · 0.95
closeMethod · 0.95
HTTP2ConnectionClass · 0.90
_get_default_user_agentFunction · 0.90

Tested by

no test coverage detected