From 453dd2c793548c1b78471069a0bc8ab067785e98 Mon Sep 17 00:00:00 2001 From: sezanzeb Date: Sun, 6 Dec 2020 12:54:14 +0100 Subject: [PATCH] testing list_names --- bin/key-mapper-service | 1 - keymapper/dev/permissions.py | 1 - keymapper/state.py | 3 +-- tests/testcases/test_keycode_mapper.py | 2 ++ tests/testcases/test_mapping.py | 15 +++++++++++++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/bin/key-mapper-service b/bin/key-mapper-service index ab5b21cc..444f1962 100755 --- a/bin/key-mapper-service +++ b/bin/key-mapper-service @@ -86,7 +86,6 @@ if __name__ == '__main__': log_info() if options.key_names: - # TODO test print('\n'.join(system_mapping.list_names())) sys.exit(0) diff --git a/keymapper/dev/permissions.py b/keymapper/dev/permissions.py index b7b4c014..04dc28df 100644 --- a/keymapper/dev/permissions.py +++ b/keymapper/dev/permissions.py @@ -34,7 +34,6 @@ from keymapper.paths import USER def check_group(group): """Check if the required group is active and log if not.""" - # TODO test try: in_group = USER in grp.getgrnam(group).gr_mem except KeyError: diff --git a/keymapper/state.py b/keymapper/state.py index dd3b083a..9b5a822e 100644 --- a/keymapper/state.py +++ b/keymapper/state.py @@ -43,7 +43,6 @@ class SystemMapping: def list_names(self): """Return an array of all possible names in the mapping.""" - # TODO test return self._mapping.keys() def populate(self): @@ -70,7 +69,7 @@ class SystemMapping: self._set(name, int(keycode) - XKB_KEYCODE_OFFSET) for name, ecode in evdev.ecodes.ecodes.items(): - if name.startswith('KEY') or name.startswith('KEY'): + if name.startswith('KEY') or name.startswith('BTN'): self._set(name, ecode) def _set(self, name, code): diff --git a/tests/testcases/test_keycode_mapper.py b/tests/testcases/test_keycode_mapper.py index 1c994533..7dbbecda 100644 --- a/tests/testcases/test_keycode_mapper.py +++ b/tests/testcases/test_keycode_mapper.py @@ -35,5 +35,7 @@ class TestKeycodeMapper(unittest.TestCase): # TODO test for macro holding + + if __name__ == "__main__": unittest.main() diff --git a/tests/testcases/test_mapping.py b/tests/testcases/test_mapping.py index 7f22d65a..70b070d6 100644 --- a/tests/testcases/test_mapping.py +++ b/tests/testcases/test_mapping.py @@ -43,6 +43,8 @@ class TestMapping(unittest.TestCase): self.assertEqual(system_mapping.get('kEY_LeFTSHIFT'), 42) self.assertEqual(system_mapping.get('ShiFt_L'), 42) + self.assertEqual(system_mapping.get('BTN_left'), 272) + self.assertIsNotNone(system_mapping.get('kp_1')) self.assertIsNotNone(system_mapping.get('KP_1')) self.assertEqual( @@ -54,6 +56,19 @@ class TestMapping(unittest.TestCase): system_mapping.get('KEY_KP4') ) + names = system_mapping.list_names() + self.assertIn('key_kp1', names) + self.assertIn('key_nextsong', names) + self.assertIn('2', names) + self.assertIn('key_3', names) + self.assertIn('c', names) + self.assertIn('key_d', names) + self.assertIn('f4', names) + self.assertIn('key_f5', names) + self.assertIn('minus', names) + self.assertIn('btn_left', names) + self.assertIn('btn_right', names) + def test_clone(self): mapping1 = Mapping() mapping1.change((EV_KEY, 1), 'a')