summaryrefslogtreecommitdiff
path: root/tests/test-dconf.py
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2019-02-09 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2019-02-12 18:59:03 +0100
commitc963f9eec8d72d6e17099d456330cd988294c0af (patch)
tree1444a893b63574b768194dce7b5a9b7cc37cc05c /tests/test-dconf.py
parent108158af9e0db6f05ff10d75e2349b7db91013ae (diff)
downloaddconf-c963f9eec8d72d6e17099d456330cd988294c0af.tar.gz
bin: Add an option to ignore changes to locked keys during load
If load command attempts to change one of non-writable keys, the whole operation fails with an error and no changes are made. Add an `-f` option to the load command that skips non-writable keys and proceeds with remaining changes. Closes issue #1.
Diffstat (limited to 'tests/test-dconf.py')
-rwxr-xr-xtests/test-dconf.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/test-dconf.py b/tests/test-dconf.py
index 1e143e2..cf9bb14 100755
--- a/tests/test-dconf.py
+++ b/tests/test-dconf.py
@@ -62,8 +62,8 @@ def dconf(*args, **kwargs):
return subprocess.run(argv, **kwargs)
-def dconf_read(key):
- return dconf('read', key).stdout.rstrip('\n')
+def dconf_read(key, **kwargs):
+ return dconf('read', key, **kwargs).stdout.rstrip('\n')
def dconf_write(key, value):
@@ -684,6 +684,7 @@ class DBusTest(unittest.TestCase):
- Update configures locks based on files found in "locks" subdirectory.
- Locks can be listed with list-locks command.
- Locks are enforced during write.
+ - Load can ignore changes to locked keys using -f option.
"""
db = os.path.join(self.temporary_dir.name, 'db')
@@ -755,6 +756,26 @@ class DBusTest(unittest.TestCase):
env=env, stderr=subprocess.PIPE)
self.assertRegex(cm.exception.stderr, 'non-writable keys')
+ keyfile = dedent('''\
+ [system/proxy/http]
+ enabled=false
+ [org/gnome/desktop]
+ background='Winter.png'
+ ''')
+
+ # Load fails to apply changes if some key is locked ...
+ with self.assertRaises(subprocess.CalledProcessError) as cm:
+ dconf('load', '/', input=keyfile, env=env, stderr=subprocess.PIPE)
+ self.assertRegex(cm.exception.stderr, 'non-writable keys')
+ self.assertEqual('true', dconf_read('/system/proxy/http/enabled', env=env))
+ self.assertEqual("'ColdWarm.jpg'", dconf_read('/org/gnome/desktop/background', env=env))
+
+ # ..., unless invoked with -f option, then it changes unlocked keys.
+ stderr = dconf('load', '-f', '/', input=keyfile, env=env, stderr=subprocess.PIPE).stderr
+ self.assertRegex(stderr, 'ignored non-writable key')
+ self.assertEqual('true', dconf_read('/system/proxy/http/enabled', env=env))
+ self.assertEqual("'Winter.png'", dconf_read('/org/gnome/desktop/background', env=env))
+
def test_dconf_blame(self):
"""Blame returns recorded information about write operations.