aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-05-02 11:49:46 +1200
committerAldo Cortesi <aldo@corte.si>2017-05-02 12:18:24 +1200
commit4e39d387d374f1f000f9ddf01c799369bfc25ddb (patch)
treeef38badd276405aa523294fd06e9794b62fef228 /test
parent9e58c36639f7faa327ec10bdc8ab8f68e7118bf0 (diff)
downloadmitmproxy-4e39d387d374f1f000f9ddf01c799369bfc25ddb.tar.gz
mitmproxy-4e39d387d374f1f000f9ddf01c799369bfc25ddb.tar.bz2
mitmproxy-4e39d387d374f1f000f9ddf01c799369bfc25ddb.zip
commands: options control
Use the new commands to bind the Options view in console.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_core.py35
-rw-r--r--test/mitmproxy/tools/console/test_help.py6
2 files changed, 35 insertions, 6 deletions
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"