(self, m_req, m_os)
| 26 | @mock.patch('aiohttp.client.os') |
| 27 | @mock.patch('aiohttp.client.ClientSession.get') |
| 28 | def test_ws_connect(self, m_req, m_os): |
| 29 | resp = mock.Mock() |
| 30 | resp.status = 101 |
| 31 | resp.headers = { |
| 32 | hdrs.UPGRADE: hdrs.WEBSOCKET, |
| 33 | hdrs.CONNECTION: hdrs.UPGRADE, |
| 34 | hdrs.SEC_WEBSOCKET_ACCEPT: self.ws_key, |
| 35 | hdrs.SEC_WEBSOCKET_PROTOCOL: 'chat' |
| 36 | } |
| 37 | m_os.urandom.return_value = self.key_data |
| 38 | m_req.return_value = asyncio.Future(loop=self.loop) |
| 39 | m_req.return_value.set_result(resp) |
| 40 | |
| 41 | res = self.loop.run_until_complete( |
| 42 | aiohttp.ws_connect( |
| 43 | 'http://test.org', |
| 44 | protocols=('t1', 't2', 'chat'), |
| 45 | loop=self.loop)) |
| 46 | |
| 47 | self.assertIsInstance(res, websocket_client.ClientWebSocketResponse) |
| 48 | self.assertEqual(res.protocol, 'chat') |
| 49 | self.assertNotIn(hdrs.ORIGIN, m_req.call_args[1]["headers"]) |
| 50 | |
| 51 | @mock.patch('aiohttp.client.os') |
| 52 | @mock.patch('aiohttp.client.ClientSession.get') |
nothing calls this directly
no test coverage detected