| 12 | |
| 13 | |
| 14 | def test_bind(): |
| 15 | with taddons.context() as tctx: |
| 16 | km = keymap.Keymap(tctx.master) |
| 17 | km.executor = mock.Mock() |
| 18 | |
| 19 | with pytest.raises(ValueError): |
| 20 | km.add("foo", "bar", ["unsupported"]) |
| 21 | |
| 22 | km.add("key", "str", ["options", "commands"]) |
| 23 | assert km.get("options", "key") |
| 24 | assert km.get("commands", "key") |
| 25 | assert not km.get("flowlist", "key") |
| 26 | assert len(km.list("commands")) == 1 |
| 27 | |
| 28 | km.handle("unknown", "unknown") |
| 29 | assert not km.executor.called |
| 30 | |
| 31 | km.handle("options", "key") |
| 32 | assert km.executor.called |
| 33 | |
| 34 | km.add("glob", "str", ["global"]) |
| 35 | km.executor = mock.Mock() |
| 36 | km.handle("options", "glob") |
| 37 | assert km.executor.called |
| 38 | |
| 39 | assert len(km.list("global")) == 1 |
| 40 | |
| 41 | |
| 42 | def test_join(): |