mirror of
https://github.com/sezanzeb/input-remapper
synced 2024-11-20 03:25:43 +00:00
test for config contents
This commit is contained in:
parent
a3f814f063
commit
ee28c59bed
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user