Skip to content

Commit aa644bf

Browse files
Ngo The Trunghyperair
Ngo The Trung
authored andcommitted
Add test for frame spillover fix
1 parent 826aaf0 commit aa644bf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/test_websocket.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,26 @@ def test_sending_ping(self):
177177
ws.ping("hello")
178178
m.sendall.assert_called_once_with(tm)
179179

180+
def test_spill_frame(self):
181+
s = MagicMock()
182+
m = MagicMock()
183+
c = MagicMock()
184+
recv = lambda size: b'a' * size
185+
186+
with patch.multiple(m, recv=recv):
187+
ws = WebSocket(sock=m)
188+
sz = 20
189+
spill = 10
190+
proc = MagicMock(return_value=('a' * sz))
191+
pend = lambda: b'a' * spill
192+
193+
with patch.multiple(ws, close=c, process=proc, _get_from_pending=pend):
194+
ws.stream = s
195+
ws.reading_buffer_size = sz
196+
ws.once()
197+
proc.assert_called_once_with(b'a' * sz)
198+
self.assertEqual(len(ws.buf), spill)
199+
180200

181201
if __name__ == '__main__':
182202
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)