Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ language: python

python:
- 2.7
- 3.5
- 3.6
- 3.7
- 3.8
- 3.9


before_install:
- sudo apt-get install python-dev libevent-dev
- pip install Cython
Expand Down
22 changes: 22 additions & 0 deletions test/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import struct

try:
from io import BytesIO
from unittest.mock import MagicMock, call, patch
except ImportError:
from StringIO import StringIO as BytesIO
from mock import MagicMock, call, patch


from ws4py.framing import Frame, \
OPCODE_CONTINUATION, OPCODE_TEXT, \
OPCODE_BINARY, OPCODE_CLOSE, OPCODE_PING, OPCODE_PONG
Expand Down Expand Up @@ -180,6 +183,25 @@ def test_sending_ping(self):
ws.ping("hello")
m.sendall.assert_called_once_with(tm)

def test_spill_frame(self):
data = b"hello"
buf = BytesIO(data + b"spillover")

sock = MagicMock()
sock._ssl = object() # for WebSocket._is_secure logic
sock.recv.side_effect = buf.read
sock.pending.side_effect = lambda: buf.tell() < len(buf.getvalue())

ws = WebSocket(sock=sock)
ws.stream = MagicMock()

self.assertTrue(ws._is_secure)

ws.reading_buffer_size = len(data)
ws.once()

ws.stream.parser.send.assert_called_once_with(data)


@patch("ws4py.websocket.Heartbeat")
def test_run(self, mocker):
Expand Down