示例#1
0
def test_send_text_masked(protocol, transport):
    writer = WebSocketWriter(protocol,
                             transport,
                             use_mask=True,
                             random=random.Random(123))
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\x81\x84\rg\xb3fy\x02\xcb\x12')
def test_send_text_masked(protocol, transport):
    writer = WebSocketWriter(protocol,
                             transport,
                             use_mask=True,
                             random=random.Random(123))
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\x81\x84\rg\xb3fy\x02\xcb\x12')
示例#3
0
def test_send_compress_text_notakeover(protocol, transport):
    writer = WebSocketWriter(protocol,
                             transport,
                             compress=15,
                             notakeover=True)
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
def test_send_compress_text_per_message(protocol, transport):
    writer = WebSocketWriter(protocol, transport)
    writer.send(b'text', compress=15)
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\x81\x04text')
    writer.send(b'text', compress=15)
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
示例#5
0
async def test_send_text_masked(protocol, transport) -> None:
    writer = WebSocketWriter(protocol,
                             transport,
                             use_mask=True,
                             random=random.Random(123))
    await writer.send(b"text")
    writer.transport.write.assert_called_with(b"\x81\x84\rg\xb3fy\x02\xcb\x12")
示例#6
0
async def test_send_compress_text_notakeover(protocol: Any,
                                             transport: Any) -> None:
    writer = WebSocketWriter(protocol, transport, compress=15, notakeover=True)
    await writer.send(b"text")
    writer.transport.write.assert_called_with(b"\xc1\x06*I\xad(\x01\x00")
    await writer.send(b"text")
    writer.transport.write.assert_called_with(b"\xc1\x06*I\xad(\x01\x00")
示例#7
0
async def test_send_compress_text_per_message(protocol, transport) -> None:
    writer = WebSocketWriter(protocol, transport)
    await writer.send(b"text", compress=15)
    writer.transport.write.assert_called_with(b"\xc1\x06*I\xad(\x01\x00")
    await writer.send(b"text")
    writer.transport.write.assert_called_with(b"\x81\x04text")
    await writer.send(b"text", compress=15)
    writer.transport.write.assert_called_with(b"\xc1\x06*I\xad(\x01\x00")
示例#8
0
def test_send_compress_text_per_message(protocol, transport):
    writer = WebSocketWriter(protocol, transport)
    writer.send(b'text', compress=15)
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\x81\x04text')
    writer.send(b'text', compress=15)
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
async def test_send_compress_text_notakeover(protocol, transport):
    writer = WebSocketWriter(protocol, transport, compress=15, notakeover=True)
    await writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    await writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
示例#10
0
def function2772(function2289, function1090):
    function1090 = WebSocketWriter(function2289, use_mask=True, random=random.Random(123))
    function1090.send(b'text')
    function2289.transport.write.assert_called_with(b'\x81\x84\rg\xb3fy\x02\xcb\x12')
def test_send_compress_text_notakeover(stream):
    writer = WebSocketWriter(stream, compress=15, notakeover=True)
    writer.send(b'text')
    stream.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    stream.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
def test_send_compress_text(stream):
    writer = WebSocketWriter(stream, compress=15)
    writer.send(b'text')
    stream.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    stream.transport.write.assert_called_with(b'\xc1\x05*\x01b\x00\x00')
def writer(stream):
    return WebSocketWriter(stream, use_mask=False)
示例#14
0
def test_send_compress_text(protocol, transport):
    writer = WebSocketWriter(protocol, transport, compress=15)
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x05*\x01b\x00\x00')
示例#15
0
def writer(protocol, transport):
    return WebSocketWriter(protocol, transport, use_mask=False)
示例#16
0
async def test_send_compress_text(protocol, transport) -> None:
    writer = WebSocketWriter(protocol, transport, compress=15)
    await writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x06*I\xad(\x01\x00')
    await writer.send(b'text')
    writer.transport.write.assert_called_with(b'\xc1\x05*\x01b\x00\x00')
示例#17
0
def function1090(function2289):
    return WebSocketWriter(function2289, use_mask=False)