File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed
Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change 11Testing
22--------
33
4- Run server
4+ Run unit tests
5+
6+ pytest
7+
8+
9+ Run functional tests
510
611 python message_lengths.py
712
Original file line number Diff line number Diff line change 11import _bootstrap_
22from websocket_server import *
3+ import pytest
4+
35
46class DummyWebsocketHandler (WebSocketHandler ):
57 def __init__ (self , * _ ):
68 pass
79
8- handler = DummyWebsocketHandler ()
9-
10- pairs = [
11- # Key # Response
12- ('zyjFH2rQwrTtNFk5lwEMQg==' , '2hnZADGmT/V1/w1GJYBtttUKASY=' ),
13- ('XJuxlsdq0QrVyKwA/D9D5A==' , 'tZ5RV3pw7nP9cF+HDvTd89WJKj8=' )
14- ]
10+ @pytest .fixture
11+ def websocket_handler ():
12+ return DummyWebsocketHandler ()
1513
16- def test_hash_calculations_for_response ():
14+ def test_hash_calculations_for_response (websocket_handler ):
1715 key = 'zyjFH2rQwrTtNFk5lwEMQg=='
18- resp = handler .calculate_response_key (key )
19- assert resp == '2hnZADGmT/V1/w1GJYBtttUKASY='
16+ expected_key = '2hnZADGmT/V1/w1GJYBtttUKASY='
17+ assert websocket_handler .calculate_response_key (key ) == expected_key
18+
2019
21- def test_response_messages ():
20+ def test_response_messages (websocket_handler ):
2221 key = 'zyjFH2rQwrTtNFk5lwEMQg=='
23- expect = \
22+ expected = \
2423 'HTTP/1.1 101 Switching Protocols\r \n ' \
2524 'Upgrade: websocket\r \n ' \
2625 'Connection: Upgrade\r \n ' \
2726 'Sec-WebSocket-Accept: 2hnZADGmT/V1/w1GJYBtttUKASY=\r \n ' \
2827 '\r \n '
29- resp = handler .make_handshake_response (key )
30- assert resp == expect
28+ handshake_content = websocket_handler .make_handshake_response (key )
29+ assert handshake_content == expected
You can’t perform that action at this time.
0 commit comments