test for reverse mapping split

This commit is contained in:
sezanzeb 2020-11-23 21:43:31 +01:00
parent 7b89e8a46f
commit 36c2ae1be0
2 changed files with 8 additions and 2 deletions

View File

@ -33,8 +33,8 @@ from keymapper.paths import get_config_path
def update_reverse_mapping(func): def update_reverse_mapping(func):
"""Generate a reverse mapping to optimize reverse lookups. """Generate a reverse mapping to optimize reverse lookups.
If _mapping contains `20: "a, A"`, If _mapping contains `20: "a, A"` (the xkb syntax for modified keys),
reverse mapping will contain `"a": 20, "A": 20` reverse mapping will contain `"a": 20, "A": 20`.
""" """
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
func(self, *args, **kwargs) func(self, *args, **kwargs)

View File

@ -45,6 +45,12 @@ class TestMapping(unittest.TestCase):
self.assertEqual(loaded.get_keycode('2'), 11) self.assertEqual(loaded.get_keycode('2'), 11)
self.assertEqual(loaded.get_keycode('3'), 12) self.assertEqual(loaded.get_keycode('3'), 12)
def test_split(self):
# mapping supports the xmodmap/xkb syntax for modified buttons
self.mapping.change(10, 'a, A')
self.assertEqual(self.mapping.get_keycode('a'), 10)
self.assertEqual(self.mapping.get_keycode('A'), 10)
def test_change(self): def test_change(self):
# 1 is not assigned yet, ignore it # 1 is not assigned yet, ignore it
self.mapping.change(2, 'a', 1) self.mapping.change(2, 'a', 1)