From f0f1fb4b556b048c5a8f93541bea751981136aba Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 17 Feb 2011 10:18:38 +1300 Subject: Add file writing to mitmdump. --- test/test_dump.py | 27 ++++++++++++++++++++++++++- test/test_flow.py | 6 +++--- 2 files changed, 29 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_dump.py b/test/test_dump.py index f9a6bdf4..9aee5a31 100644 --- a/test/test_dump.py +++ b/test/test_dump.py @@ -1,6 +1,7 @@ +import os from cStringIO import StringIO import libpry -from libmproxy import dump +from libmproxy import dump, flow import utils @@ -28,6 +29,30 @@ class uDumpMaster(libpry.AutoTree): self._dummy_cycle(m) assert "GET" in cs.getvalue() + def test_write(self): + d = self.tmpdir() + p = os.path.join(d, "a") + o = dump.Options( + wfile = p, + verbosity = 0 + ) + cs = StringIO() + m = dump.DumpMaster(None, o, cs) + self._dummy_cycle(m) + del m + assert len(list(flow.FlowReader(open(p)).stream())) == 1 + + def test_write_err(self): + o = dump.Options( + wfile = "nonexistentdir/foo", + verbosity = 0 + ) + cs = StringIO() + libpry.raises(dump.DumpError, dump.DumpMaster, None, o, cs) + + + + tests = [ diff --git a/test/test_flow.py b/test/test_flow.py index 7354061b..9871b090 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -141,12 +141,12 @@ class uState(libpry.AutoTree): assert c.lookup(req) newreq = utils.treq() - assert not c.add_request(newreq) - assert not c.lookup(newreq) + assert c.add_request(newreq) + assert c.lookup(newreq) resp = utils.tresp(req) assert c.add_response(resp) - assert len(c.flow_list) == 1 + assert len(c.flow_list) == 2 assert c.lookup(resp) newresp = utils.tresp() -- cgit v1.2.3