MCPcopy Create free account
hub / github.com/aio-libs/aiohttp / test_https_connect_pass_ssl_context

Method test_https_connect_pass_ssl_context

tests/test_proxy.py:985–1055  ·  view source on GitHub ↗
(
        self, start_connection: Any, ClientRequestMock: Any
    )

Source from the content-addressed store, hash-verified

983 spec_set=True,
984 )
985 def test_https_connect_pass_ssl_context(
986 self, start_connection: Any, ClientRequestMock: Any
987 ) -> None:
988 proxy_req = ClientRequest(
989 "GET", URL("http://proxy.example.com"), loop=self.loop
990 )
991 ClientRequestMock.return_value = proxy_req
992
993 proxy_resp = ClientResponse(
994 "get",
995 URL("http://proxy.example.com"),
996 request_info=mock.Mock(),
997 writer=None,
998 continue100=None,
999 timer=TimerNoop(),
1000 traces=[],
1001 loop=self.loop,
1002 stream_writer=mock.create_autospec(
1003 AbstractStreamWriter, spec_set=True, instance=True
1004 ),
1005 session=mock.Mock(),
1006 )
1007 proxy_req.send = mock.AsyncMock(return_value=proxy_resp)
1008 proxy_resp.start = mock.AsyncMock(return_value=mock.Mock(status=200))
1009
1010 async def make_conn():
1011 return aiohttp.TCPConnector()
1012
1013 connector = self.loop.run_until_complete(make_conn())
1014 connector._resolve_host = mock.AsyncMock(
1015 return_value=[
1016 {
1017 "hostname": "hostname",
1018 "host": "127.0.0.1",
1019 "port": 80,
1020 "family": socket.AF_INET,
1021 "proto": 0,
1022 "flags": 0,
1023 }
1024 ]
1025 )
1026
1027 tr, proto = mock.Mock(), mock.Mock()
1028 self.loop.create_connection = mock.AsyncMock(return_value=(tr, proto))
1029 self.loop.start_tls = mock.AsyncMock(return_value=mock.Mock())
1030
1031 req = ClientRequest(
1032 "GET",
1033 URL("https://www.python.org"),
1034 proxy=URL("http://proxy.example.com"),
1035 loop=self.loop,
1036 )
1037 self.loop.run_until_complete(
1038 connector._create_connection(req, None, aiohttp.ClientTimeout())
1039 )
1040 # ssl_shutdown_timeout=0 is not passed to start_tls
1041 self.loop.start_tls.assert_called_with(
1042 mock.ANY,

Callers

nothing calls this directly

Calls 7

closeMethod · 0.95
closeMethod · 0.95
ClientRequestClass · 0.90
ClientResponseClass · 0.90
TimerNoopClass · 0.90
make_connFunction · 0.70
_create_connectionMethod · 0.45

Tested by

no test coverage detected