aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-06-02 10:45:17 +1200
committerAldo Cortesi <aldo@nullcube.com>2011-06-02 10:45:17 +1200
commit62f9864395fcb9933992257d5beabf84e532f85f (patch)
treeafe048a485913801fd04f8e0baf9678234cedfcc /test
parent1de5209340cf0f032a93244bee1696abbb879154 (diff)
parent07110bbbf192339b52d1067b531d0cea20b245d2 (diff)
downloadmitmproxy-62f9864395fcb9933992257d5beabf84e532f85f.tar.gz
mitmproxy-62f9864395fcb9933992257d5beabf84e532f85f.tar.bz2
mitmproxy-62f9864395fcb9933992257d5beabf84e532f85f.zip
Merge branch 'master' of github.com:cortesi/mitmproxy
Diffstat (limited to 'test')
-rw-r--r--test/test_flow.py21
-rw-r--r--test/tutils.py7
2 files changed, 28 insertions, 0 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index a6489462..b7a368d2 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -369,6 +369,19 @@ class uState(libpry.AutoTree):
class uSerialize(libpry.AutoTree):
+ def _treader(self):
+ sio = StringIO()
+ w = flow.FlowWriter(sio)
+ for i in range(3):
+ f = tutils.tflow_full()
+ w.add(f)
+ for i in range(3):
+ f = tutils.tflow_err()
+ w.add(f)
+
+ sio.seek(0)
+ return flow.FlowReader(sio)
+
def test_roundtrip(self):
sio = StringIO()
f = tutils.tflow()
@@ -381,6 +394,14 @@ class uSerialize(libpry.AutoTree):
assert len(l) == 1
assert l[0] == f
+ def test_load_flows(self):
+ r = self._treader()
+ s = flow.State()
+ fm = flow.FlowMaster(None, s)
+ fm.load_flows(r)
+ assert len(s.flow_list) == 6
+
+
def test_error(self):
sio = StringIO()
sio.write("bogus")
diff --git a/test/tutils.py b/test/tutils.py
index fea7f224..2327bdb9 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -32,6 +32,13 @@ def tflow_full():
return f
+def tflow_err():
+ r = treq()
+ f = flow.Flow(r)
+ f.error = proxy.Error(r, "error")
+ return f
+
+
# Yes, the random ports are horrible. During development, sockets are often not
# properly closed during error conditions, which means you have to wait until
# you can re-bind to the same port. This is a pain in the ass, so we just pick