(self, ClientRequestMock)
| 192 | |
| 193 | @unittest.mock.patch('aiohttp.connector.ClientRequest') |
| 194 | def test_https_connect(self, ClientRequestMock): |
| 195 | loop_mock = unittest.mock.Mock() |
| 196 | proxy_req = ClientRequest('GET', 'http://proxy.example.com', |
| 197 | loop=loop_mock) |
| 198 | ClientRequestMock.return_value = proxy_req |
| 199 | |
| 200 | proxy_resp = ClientResponse('get', 'http://proxy.example.com') |
| 201 | proxy_resp._loop = loop_mock |
| 202 | proxy_req.send = send_mock = unittest.mock.Mock() |
| 203 | send_mock.return_value = proxy_resp |
| 204 | proxy_resp.start = start_mock = unittest.mock.Mock() |
| 205 | self._fake_coroutine(start_mock, unittest.mock.Mock(status=200)) |
| 206 | |
| 207 | connector = aiohttp.ProxyConnector( |
| 208 | 'http://proxy.example.com', loop=loop_mock) |
| 209 | |
| 210 | tr, proto = unittest.mock.Mock(), unittest.mock.Mock() |
| 211 | self._fake_coroutine(loop_mock.create_connection, (tr, proto)) |
| 212 | |
| 213 | req = ClientRequest('GET', 'https://www.python.org', loop=self.loop) |
| 214 | self.loop.run_until_complete(connector._create_connection(req)) |
| 215 | |
| 216 | self.assertEqual(req.path, '/') |
| 217 | self.assertEqual(proxy_req.method, 'CONNECT') |
| 218 | self.assertEqual(proxy_req.path, 'www.python.org:443') |
| 219 | tr.pause_reading.assert_called_once_with() |
| 220 | tr.get_extra_info.assert_called_with('socket', default=None) |
| 221 | |
| 222 | self.loop.run_until_complete(proxy_req.close()) |
| 223 | proxy_resp.close() |
| 224 | self.loop.run_until_complete(req.close()) |
| 225 | |
| 226 | @unittest.mock.patch('aiohttp.connector.ClientRequest') |
| 227 | def test_https_connect_runtime_error(self, ClientRequestMock): |
nothing calls this directly
no test coverage detected