From 4e39d387d374f1f000f9ddf01c799369bfc25ddb Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 2 May 2017 11:49:46 +1200 Subject: commands: options control Use the new commands to bind the Options view in console. --- test/mitmproxy/addons/test_core.py | 35 +++++++++++++++++++++++++++++++ test/mitmproxy/tools/console/test_help.py | 6 ------ 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py index eaf0dfa0..3c3c7bf7 100644 --- a/test/mitmproxy/addons/test_core.py +++ b/test/mitmproxy/addons/test_core.py @@ -128,3 +128,38 @@ def test_encoding(): with pytest.raises(exceptions.CommandError): sa.encode([f], "request", "invalid") + + +def test_options(tmpdir): + p = str(tmpdir.join("path")) + sa = core.Core() + with taddons.context() as tctx: + tctx.options.stickycookie = "foo" + assert tctx.options.stickycookie == "foo" + sa.options_reset() + assert tctx.options.stickycookie is None + + tctx.options.stickycookie = "foo" + tctx.options.stickyauth = "bar" + sa.options_reset_one("stickycookie") + assert tctx.options.stickycookie is None + assert tctx.options.stickyauth == "bar" + + with pytest.raises(exceptions.CommandError): + sa.options_reset_one("unknown") + + sa.options_save(p) + with pytest.raises(exceptions.CommandError): + sa.options_save("/nonexistent") + + sa.options_reset() + assert tctx.options.stickyauth is None + sa.options_load(p) + assert tctx.options.stickyauth == "bar" + + sa.options_load("/nonexistent") + + with open(p, 'a') as f: + f.write("'''") + with pytest.raises(exceptions.CommandError): + sa.options_load(p) diff --git a/test/mitmproxy/tools/console/test_help.py b/test/mitmproxy/tools/console/test_help.py index ac3011e6..0ebc2d6a 100644 --- a/test/mitmproxy/tools/console/test_help.py +++ b/test/mitmproxy/tools/console/test_help.py @@ -9,9 +9,3 @@ class TestHelp: def test_helptext(self): h = help.HelpView(None) assert h.helptext() - - def test_keypress(self): - h = help.HelpView([1, 2, 3]) - assert not h.keypress((0, 0), "q") - assert not h.keypress((0, 0), "?") - assert h.keypress((0, 0), "o") == "o" -- cgit v1.2.3