[tracker/gsettings-remaining-bits] functional-tests: Make sure to use a fresh dconf profile



commit 26a5a6eb2a72f2bf67e44ba66ba8673856a97ab4
Author: Ivan Frade <ivan frade nokia com>
Date:   Tue Mar 22 13:30:56 2011 +0200

    functional-tests: Make sure to use a fresh dconf profile

 tests/functional-tests/common/utils/dconf.py  |   39 ++++++++++++++++---------
 tests/functional-tests/common/utils/system.py |    1 +
 2 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/dconf.py b/tests/functional-tests/common/utils/dconf.py
index 32d483a..a1d099a 100644
--- a/tests/functional-tests/common/utils/dconf.py
+++ b/tests/functional-tests/common/utils/dconf.py
@@ -1,18 +1,12 @@
 import subprocess
+import os
 
 class DConfClient:
     """
     Shamefull implementation until we get GobjectIntrospection on libdconf
     """
-    SCHEMA_MINER = "org.freedesktop.Tracker.Miner.FileSystem"
-    
     def write (self, schema, key, value):
-        if (type(value) == int):
-            v = "i'%d'" % (value)
-        else:
-            v = value
-        command = ["gsettings", "set", schema, key, v]
-        print command
+        command = ["gsettings", "set", schema, key, str(value)]
         FNULL = open('/dev/null', 'w')
         cmd = subprocess.Popen (command, stdout=subprocess.PIPE) #, stdout=FNULL, stderr=FNULL)
         cmd.wait ()
@@ -24,18 +18,35 @@ class DConfClient:
         cmd = subprocess.Popen (command, stdout=subprocess.PIPE) #, stdout=FNULL, stderr=FNULL)
         return cmd.stdout.readline ()
 
+    def reset (self):
+        profile = os.environ ["DCONF_PROFILE"]
+        assert profile == "trackertest"
+        # XDG_CONFIG_HOME is useless
+        dconf_db = os.path.join (os.environ ["HOME"], ".config", "dconf", profile)
+        print "Removing dconf-profile:", 
+        os.remove (dconf_db)
+
 
 if __name__ == "__main__":
 
+
+    SCHEMA_MINER = "org.freedesktop.Tracker.Miner.Files"
+    os.environ ["DCONF_PROFILE"] = "trackertest"
+
     dconf = DConfClient ()
     value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
     print "Original value:", int (value)
     print "Setting 5"
-    dconf.write (DConfClient.SCHEMA_MINER, "throttle", 5)
+    dconf.write (DConfClient.SCHEMA_MINER, "throttle", "5")
     value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
-    print "Current value:", int (value)
-    print "Set 3"
-    dconf.write (DConfClient.SCHEMA_MINER, "throttle", 3)
+    assert int(value) == 5
+    
+    print "Setting 3"
+    dconf.write (DConfClient.SCHEMA_MINER, "throttle", "3")
     value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
-    print "Current value:", int (value)
-        
+    assert int (value) == 3
+
+    print "Now with lists"
+    dconf.write (DConfClient.SCHEMA_MINER, "index-recursive-directories", ['$HOME/set-with-python'])
+    value = dconf.read (DConfClient.SCHEMA_MINER, "index-recursive-directories")
+    print "result", value
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index 74065f4..e4f3d4a 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -330,6 +330,7 @@ class TrackerSystemAbstraction:
         # Previous loop should have set DCONF_PROFILE to the test location
         if gsettings:
             self.dconf = DConfClient ()
+            self.dconf.reset ()
             for (schema, key, value) in gsettings:
                 self.dconf.write (schema, key, value)
 



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