From e581e846fa518ffa2be5dda5b1fc8180114a1976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 11 Nov 2018 00:00:00 +0000 Subject: tests: Add test for compile command processing order --- tests/test-dconf.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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. -- cgit v1.2.1