blob: bbca4ac9af58a4dfc6ca21f0e096de9259252439 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
from mitmproxy.tools.console import keymap
from mitmproxy.test import taddons
from unittest import mock
import pytest
def test_bind():
with taddons.context() as tctx:
km = keymap.Keymap(tctx.master)
km.executor = mock.Mock()
with pytest.raises(ValueError):
km.add("foo", "bar", ["unsupported"])
km.add("key", "str", ["options", "commands"])
assert km.get("options", "key")
assert km.get("commands", "key")
assert not km.get("flowlist", "key")
assert len((km.list("commands"))) == 1
km.handle("unknown", "unknown")
assert not km.executor.called
km.handle("options", "key")
assert km.executor.called
km.add("glob", "str", ["global"])
km.executor = mock.Mock()
km.handle("options", "glob")
assert km.executor.called
assert len((km.list("global"))) == 1
|