From 21ef35fd281a3f0783b08276db8407b12f33ae5d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 20 Jul 2012 20:14:35 +1200 Subject: Much simpler rewrite of inner data sending loop. We don't have to do the asynchronous code contortion anymore. --- test/test_rparse.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'test/test_rparse.py') diff --git a/test/test_rparse.py b/test/test_rparse.py index cb1076c2..f4b408b2 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -250,6 +250,18 @@ class TestParseResponse: class TestWriteValues: + def test_send_chunk(self): + v = "foobarfoobar" + for bs in range(1, len(v)+2): + s = cStringIO.StringIO() + rparse.send_chunk(s, v, bs, 0, len(v)) + assert s.getvalue() == v + for start in range(len(v)): + for end in range(len(v)): + s = cStringIO.StringIO() + rparse.send_chunk(s, v, bs, start, end) + assert s.getvalue() == v[start:end] + def test_write_values_disconnects(self): s = cStringIO.StringIO() tst = "foo"*100 @@ -257,11 +269,17 @@ class TestWriteValues: assert not s.getvalue() def test_write_values(self): - tst = "foo"*1025 + tst = "foobarvoing" s = cStringIO.StringIO() rparse.write_values(s, [tst], []) assert s.getvalue() == tst + for bs in range(1, len(tst) + 2): + for off in range(len(tst)): + s = cStringIO.StringIO() + rparse.write_values(s, [tst], [(off, "disconnect")], blocksize=bs) + assert s.getvalue() == tst[:off] + def test_write_values_pauses(self): tst = "".join(str(i) for i in range(10)) for i in range(2, 10): -- cgit v1.2.3