aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_rparse.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-20 20:14:35 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-20 20:14:35 +1200
commit21ef35fd281a3f0783b08276db8407b12f33ae5d (patch)
tree53b088e606aa0f190e5898521a207cb13404ffef /test/test_rparse.py
parent3d9e8b2dbf7057fdcc72c74e1ffa265631750c98 (diff)
downloadmitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.tar.gz
mitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.tar.bz2
mitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.zip
Much simpler rewrite of inner data sending loop.
We don't have to do the asynchronous code contortion anymore.
Diffstat (limited to 'test/test_rparse.py')
-rw-r--r--test/test_rparse.py20
1 files changed, 19 insertions, 1 deletions
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):