Skip to content

Commit

Permalink
Add test for frame spillover fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ngo The Trung authored and hyperair committed Aug 21, 2019
1 parent 961c07c commit 0febc69
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ def test_sending_ping(self):
ws.ping("hello")
m.sendall.assert_called_once_with(tm)

def test_spill_frame(self):
s = MagicMock()
m = MagicMock()
c = MagicMock()
recv = lambda size: b'a' * size

with patch.multiple(m, recv=recv):
ws = WebSocket(sock=m)
sz = 20
spill = 10
proc = MagicMock(return_value=('a' * sz))
pend = lambda: b'a' * spill

with patch.multiple(ws, close=c, process=proc, _get_from_pending=pend):
ws.stream = s
ws.reading_buffer_size = sz
ws.once()
proc.assert_called_once_with(b'a' * sz)
self.assertEqual(len(ws.buf), spill)


if __name__ == '__main__':
suite = unittest.TestSuite()
Expand Down

0 comments on commit 0febc69

Please sign in to comment.