MCPcopy
hub / github.com/aio-libs/aiohttp / test_connect

Method test_connect

tests/test_connector.py:262–284  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

260 self.assertTrue(tr.close.called)
261
262 def test_connect(self):
263 tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
264 proto.is_connected.return_value = True
265
266 class Req:
267 host = 'host'
268 port = 80
269 ssl = False
270 response = unittest.mock.Mock()
271
272 conn = aiohttp.BaseConnector(loop=self.loop)
273 key = ('host', 80, False)
274 conn._conns[key] = [(tr, proto, self.loop.time())]
275 conn._create_connection = unittest.mock.Mock()
276 conn._create_connection.return_value = asyncio.Future(loop=self.loop)
277 conn._create_connection.return_value.set_result((tr, proto))
278
279 connection = self.loop.run_until_complete(conn.connect(Req()))
280 self.assertFalse(conn._create_connection.called)
281 self.assertEqual(connection._transport, tr)
282 self.assertEqual(connection._protocol, proto)
283 self.assertIsInstance(connection, Connection)
284 connection.close()
285
286 def test_connect_timeout(self):
287 conn = aiohttp.BaseConnector(loop=self.loop)

Callers

nothing calls this directly

Calls 3

connectMethod · 0.95
ReqClass · 0.85
closeMethod · 0.45

Tested by

no test coverage detected