diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_flow.py | 21 | ||||
-rw-r--r-- | test/tutils.py | 7 |
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 |