From ee28c59bedf9336eec4bc34f4592c6815f9e07b7 Mon Sep 17 00:00:00 2001 From: sezanzeb Date: Sat, 31 Oct 2020 15:29:25 +0100 Subject: [PATCH] test for config contents --- keymapper/config.py | 9 +-------- keymapper/devices.py | 7 ++++++- tests/testcases/config.py | 6 ++++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/keymapper/config.py b/keymapper/config.py index 2ccff25f..03814e06 100644 --- a/keymapper/config.py +++ b/keymapper/config.py @@ -145,17 +145,10 @@ class Config: def get(self, key): """Read a value from the configuration or get the default.""" self.check_mtime() - if key not in _defaults: - logger.error('Unknown setting %s', key) - return None return self._config.get(key, _defaults[key]) def set(self, key, value): - """Write a setting into memory and ~/.config/key-mapper/config.""" - if key not in _defaults: - logger.error('Unknown setting %s', key) - return None - + """Write a setting into memory and ~/.config/key-mapper/.""" self.check_mtime() if key in self._config and self._config[key] == value: diff --git a/keymapper/devices.py b/keymapper/devices.py index bd171932..34632c4d 100644 --- a/keymapper/devices.py +++ b/keymapper/devices.py @@ -32,5 +32,10 @@ def find_devices(): def get_presets(device): - """Get all configured presets for the device""" + """Get all configured presets for the device.""" + pass + + +def get_mappings(device, preset): + """Get all configured buttons of the preset.""" pass diff --git a/tests/testcases/config.py b/tests/testcases/config.py index 3164ce67..cee7bf69 100644 --- a/tests/testcases/config.py +++ b/tests/testcases/config.py @@ -56,6 +56,12 @@ class ConfigTest(unittest.TestCase): get_config('device2', 'preset3', '/tmp/key-mapper') self.assertTrue(os.path.isfile('/tmp/key-mapper/device2/preset3')) + config.set('key1', 'value') + config.set('key2', 123) + with open('/tmp/key-mapper/device1/preset1', 'r') as f: + contents = f.read() + self.assertEqual(contents, 'key1=value\nkey2=123\n') + if __name__ == "__main__": unittest.main()