#NEWLINE# @ mock . patch ( 'aiohttp.client.os' ) #NEWLINE# @ mock . patch ( 'aiohttp.client.ClientSession.get' ) #NEWLINE# def test_ws_connect( self , m_req , m_os ) : #NEWLINE# #INDENT# resp = mock . Mock ( ) #NEWLINE# resp . status = 101 #NEWLINE# resp . headers = { #NEWLINE# #INDENT# hdrs . UPGRADE : hdrs . WEBSOCKET , #NEWLINE# hdrs . CONNECTION : hdrs . UPGRADE , #NEWLINE# hdrs . SEC_WEBSOCKET_ACCEPT : self . ws_key , #NEWLINE# hdrs . SEC_WEBSOCKET_PROTOCOL : 'chat' , #NEWLINE# #UNINDENT# } #NEWLINE# m_os . urandom . return_value = self . key_data #NEWLINE# m_req . return_value = asyncio . Future ( loop = self . loop ) #NEWLINE# m_req . return_value . set_result ( resp ) #NEWLINE# res = self . loop . run_until_complete ( aiohttp . ws_connect ( 'http://test.org' , protocols = ( 't1' , 't2' , 'chat' ) , loop = self . loop ) ) #NEWLINE# self . assertIsInstance ( res , websocket_client . ClientWebSocketResponse ) #NEWLINE# self . assertEqual ( res . protocol , 'chat' ) #NEWLINE# self . assertNotIn ( hdrs . ORIGIN , m_req . call_args [ 1 ] [ 'headers' ] )