summaryrefslogtreecommitdiff
path: root/tests/test-dconf.py
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2018-11-11 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2018-11-13 08:51:30 +0100
commite581e846fa518ffa2be5dda5b1fc8180114a1976 (patch)
tree703fbd3594ddf8b9ae09d93989032386688ea339 /tests/test-dconf.py
parente69c3d40c5d46d18d231257037d5d85c24b0aaba (diff)
downloaddconf-e581e846fa518ffa2be5dda5b1fc8180114a1976.tar.gz
tests: Add test for compile command processing order
Diffstat (limited to 'tests/test-dconf.py')
-rwxr-xr-xtests/test-dconf.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test-dconf.py b/tests/test-dconf.py
index ab71124..e520e5b 100755
--- a/tests/test-dconf.py
+++ b/tests/test-dconf.py
@@ -370,6 +370,45 @@ class DBusTest(unittest.TestCase):
['/org/calculator/',
'/org/calendar/'])
+ def test_compile_precedence(self):
+ """Compile processes key-files in reverse lexicographical order.
+
+ When key occurs in multiple files, the value from file processed first
+ is preferred.
+
+ Test that by preparing four key-files each with a different value for
+ '/org/file'. Compiling it directly into user database, and performing
+ read to check which value had been selected.
+ """
+ # Prepare key file database directory.
+ user_d = os.path.join(self.temporary_dir.name, 'user.d')
+ os.mkdir(user_d, mode=0o700)
+
+ # Required from compile utility specifically.
+ os.mkdir(os.path.join(self.config_home, 'dconf'), mode=0o700)
+
+ def write_config_d(name):
+ keyfile = dedent('''
+ [org]
+ file = {name}
+ '''.format(name=name))
+
+ with open(os.path.join(user_d, name), 'w') as file:
+ file.write(keyfile)
+
+ write_config_d('00')
+ write_config_d('25')
+ write_config_d('50')
+ write_config_d('99')
+
+ # Compile directly into user configuration file.
+ dconf('compile',
+ os.path.join(self.config_home, 'dconf', 'user'),
+ user_d)
+
+ # Lexicographically last value should win:
+ self.assertEqual(dconf_read('/org/file'), '99')
+
if __name__ == '__main__':
# Make sure we don't pick up mandatory profile.