From 97000aa85c6d4cd52d97bda66b0c05ffed93e9da Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 27 Apr 2017 17:05:00 +1200 Subject: command: save.file flowspec path -> None Our first user-facing command. The following commands do the obvious things: save.file @marked /tmp/flows save.file @focus /tmp/flows save.file @hidden /tmp/flows save.file "~m get" /tmp/flows --- test/mitmproxy/addons/test_save.py | 21 +++++++++++++++++++++ test/mitmproxy/test_addonmanager.py | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/addons/test_save.py b/test/mitmproxy/addons/test_save.py index fcd2feab..85c2a398 100644 --- a/test/mitmproxy/addons/test_save.py +++ b/test/mitmproxy/addons/test_save.py @@ -7,6 +7,7 @@ from mitmproxy import io from mitmproxy import exceptions from mitmproxy import options from mitmproxy.addons import save +from mitmproxy.addons import view def test_configure(tmpdir): @@ -42,6 +43,26 @@ def test_tcp(tmpdir): assert rd(p) +def test_save_command(tmpdir): + sa = save.Save() + with taddons.context() as tctx: + p = str(tmpdir.join("foo")) + sa.save([tflow.tflow(resp=True)], p) + assert len(rd(p)) == 1 + sa.save([tflow.tflow(resp=True)], p) + assert len(rd(p)) == 1 + sa.save([tflow.tflow(resp=True)], "+" + p) + assert len(rd(p)) == 2 + + with pytest.raises(exceptions.CommandError): + sa.save([tflow.tflow(resp=True)], str(tmpdir)) + + v = view.View() + tctx.master.addons.add(v) + tctx.master.addons.add(sa) + tctx.master.commands.call_args("save.file", ["@shown", p]) + + def test_simple(tmpdir): sa = save.Save() with taddons.context() as tctx: diff --git a/test/mitmproxy/test_addonmanager.py b/test/mitmproxy/test_addonmanager.py index 7b461580..fc1db941 100644 --- a/test/mitmproxy/test_addonmanager.py +++ b/test/mitmproxy/test_addonmanager.py @@ -61,9 +61,9 @@ def test_lifecycle(): a = addonmanager.AddonManager(m) a.add(TAddon("one")) - with pytest.raises(exceptions.AddonError): + with pytest.raises(exceptions.AddonManagerError): a.add(TAddon("one")) - with pytest.raises(exceptions.AddonError): + with pytest.raises(exceptions.AddonManagerError): a.remove(TAddon("nonexistent")) f = tflow.tflow() -- cgit v1.2.3