1import _bootstrap_ 2from websocket_server import WebSocketHandler 3 4 5def test_hash_calculations_for_response(): 6 assert WebSocketHandler.calculate_response_key('zyjFH2rQwrTtNFk5lwEMQg==') == '2hnZADGmT/V1/w1GJYBtttUKASY=' 7 8 9def test_response_messages(): 10 key = 'zyjFH2rQwrTtNFk5lwEMQg==' 11 expected = \ 12 'HTTP/1.1 101 Switching Protocols\r\n'\ 13 'Upgrade: websocket\r\n' \ 14 'Connection: Upgrade\r\n' \ 15 'Sec-WebSocket-Accept: 2hnZADGmT/V1/w1GJYBtttUKASY=\r\n'\ 16 '\r\n' 17 handshake_content = WebSocketHandler.make_handshake_response(key) 18 assert handshake_content == expected 19