blob: 0b2647ef309cbc2f7ed2232e8bff87374f7e9b54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from netlib import test
from netlib.websockets import implementations as impl
from netlib.websockets import websockets as ws
import os
class TestWebSockets(test.ServerTestBase):
handler = impl.WebSocketsEchoHandler
def echo(self, msg):
client = impl.WebSocketsClient(("127.0.0.1", self.port))
client.connect()
client.send_message(msg)
response = client.read_next_message()
print "Assert response: " + response + " == msg: " + msg
assert response == msg
def test_simple_echo(self):
self.echo("hello I'm the client")
def test_frame_sizes(self):
small_string = os.urandom(100) # length can fit in the the 7 bit payload length
medium_string = os.urandom(50000) # 50kb, sligthly larger than can fit in a 7 bit int
large_string = os.urandom(150000) # 150kb, slightly larger than can fit in a 16 bit int
self.echo(small_string)
self.echo(medium_string)
self.echo(large_string)
|