diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-06-14 11:09:26 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 11:09:26 +1200 |
commit | 309274689c3d2eb910b368218706cecbfcc11044 (patch) | |
tree | e1c4946bf2319872c80df0bfaca98f1455fe2266 /test | |
parent | 08972c3f5bb76b6ff60ea3124c85e3e3cd6f30f0 (diff) | |
parent | e8939b8b9fd53f49cc06f1f75c88ca9e63823b9e (diff) | |
download | mitmproxy-309274689c3d2eb910b368218706cecbfcc11044.tar.gz mitmproxy-309274689c3d2eb910b368218706cecbfcc11044.tar.bz2 mitmproxy-309274689c3d2eb910b368218706cecbfcc11044.zip |
Merge pull request #2397 from cortesi/neverenoughconsole
console: keymap-related improvements
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/tools/console/test_keymap.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/mitmproxy/tools/console/test_keymap.py b/test/mitmproxy/tools/console/test_keymap.py index bbca4ac9..00e64991 100644 --- a/test/mitmproxy/tools/console/test_keymap.py +++ b/test/mitmproxy/tools/console/test_keymap.py @@ -4,6 +4,11 @@ from unittest import mock import pytest +def test_binding(): + b = keymap.Binding("space", "cmd", ["options"], "") + assert b.keyspec() == " " + + def test_bind(): with taddons.context() as tctx: km = keymap.Keymap(tctx.master) @@ -30,3 +35,38 @@ def test_bind(): assert km.executor.called assert len((km.list("global"))) == 1 + + +def test_join(): + with taddons.context() as tctx: + km = keymap.Keymap(tctx.master) + km.add("key", "str", ["options"], "help1") + km.add("key", "str", ["commands"]) + return + assert len(km.bindings) == 1 + assert len(km.bindings[0].contexts) == 2 + assert km.bindings[0].help == "help1" + km.add("key", "str", ["commands"], "help2") + assert len(km.bindings) == 1 + assert len(km.bindings[0].contexts) == 2 + assert km.bindings[0].help == "help2" + + assert km.get("commands", "key") + km.unbind(km.bindings[0]) + assert len(km.bindings) == 0 + assert not km.get("commands", "key") + + +def test_remove(): + with taddons.context() as tctx: + km = keymap.Keymap(tctx.master) + km.add("key", "str", ["options", "commands"], "help1") + assert len(km.bindings) == 1 + assert "options" in km.bindings[0].contexts + + km.remove("key", ["options"]) + assert len(km.bindings) == 1 + assert "options" not in km.bindings[0].contexts + + km.remove("key", ["commands"]) + assert len(km.bindings) == 0 |