[dconf: 4/6] tests: Add test for compile command processing order



commit e581e846fa518ffa2be5dda5b1fc8180114a1976
Author: Tomasz MiÄ…sko <tomasz miasko gmail com>
Date:   Sun Nov 11 00:00:00 2018 +0000

    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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]