[tracker/sam/functional-test-fixes: 9/20] functional-tests: Use GLib from PyGI instead of old PyGLib module



commit 193e3037f16645d4df0a5772cd7e5791eba29f5b
Author: Sam Thursfield <sam afuera me uk>
Date:   Sun Jul 20 13:25:50 2014 +0100

    functional-tests: Use GLib from PyGI instead of old PyGLib module
    
    This allows using new GLib functionality like GLib.Source.set_name().

 tests/functional-tests/13-threaded-store.py        |    6 ++--
 tests/functional-tests/14-signals.py               |    6 ++--
 .../functional-tests/301-miner-resource-removal.py |    2 +-
 tests/functional-tests/common/utils/helpers.py     |   28 ++++++++++----------
 tests/functional-tests/common/utils/system.py      |    4 +-
 5 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/tests/functional-tests/13-threaded-store.py b/tests/functional-tests/13-threaded-store.py
index b0d7cc8..bda0adc 100755
--- a/tests/functional-tests/13-threaded-store.py
+++ b/tests/functional-tests/13-threaded-store.py
@@ -23,7 +23,7 @@ Test that the threads in the daemon are working:
 """
 import os, dbus
 from gi.repository import GObject
-import glib
+from gi.repository import GLib
 import time
 from dbus.mainloop.glib import DBusGMainLoop
 
@@ -101,8 +101,8 @@ class TestThreadedStore (CommonTrackerStoreTest):
                                                        reply_handler=self.reply_complex,
                                                        error_handler=self.error_handler_complex)
 
-        self.timeout_id = glib.timeout_add_seconds (MAX_TEST_TIME, self.__timeout_on_idle)
-        glib.timeout_add_seconds (SIMPLE_QUERY_FREQ, self.__simple_query)
+        self.timeout_id = GLib.timeout_add_seconds (MAX_TEST_TIME, self.__timeout_on_idle)
+        GLib.timeout_add_seconds (SIMPLE_QUERY_FREQ, self.__simple_query)
         self.main_loop.run ()
 
     def __simple_query (self):
diff --git a/tests/functional-tests/14-signals.py b/tests/functional-tests/14-signals.py
index c5fce41..19b01fa 100755
--- a/tests/functional-tests/14-signals.py
+++ b/tests/functional-tests/14-signals.py
@@ -28,7 +28,7 @@ from common.utils.storetest import CommonTrackerStoreTest as CommonTrackerStoreT
 from common.utils import configuration as cfg
 
 from gi.repository import GObject
-import glib
+from gi.repository import GLib
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
 import time
@@ -79,7 +79,7 @@ class TrackerStoreSignalsTests (CommonTrackerStoreTest):
         """
         In the callback of the signals, there should be a self.loop.quit ()
         """
-        self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self.__timeout_on_idle)
+        self.timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT, self.__timeout_on_idle)
         self.loop.run ()
 
     def __timeout_on_idle (self):
@@ -100,7 +100,7 @@ class TrackerStoreSignalsTests (CommonTrackerStoreTest):
         self.results_inserts = inserts
 
         if (self.timeout_id != 0):
-            glib.source_remove (self.timeout_id )
+            GLib.source_remove (self.timeout_id )
             self.timeout_id = 0
         self.loop.quit ()
         self.bus._clean_up_signal_match (self.cb_id)
diff --git a/tests/functional-tests/301-miner-resource-removal.py 
b/tests/functional-tests/301-miner-resource-removal.py
index c50cb6d..976c82e 100755
--- a/tests/functional-tests/301-miner-resource-removal.py
+++ b/tests/functional-tests/301-miner-resource-removal.py
@@ -30,7 +30,7 @@ from common.utils.system import TrackerSystemAbstraction
 from gi.repository import GLib
 
 import dbus
-import glib
+from gi.repository import GLib
 import os
 import shutil
 import unittest2 as ut
diff --git a/tests/functional-tests/common/utils/helpers.py b/tests/functional-tests/common/utils/helpers.py
index 3a79a50..1d6b98a 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -18,7 +18,7 @@
 # 02110-1301, USA.
 #
 import dbus
-import glib
+from gi.repository import GLib
 from gi.repository import GObject
 import commands
 import os
@@ -146,20 +146,20 @@ class Helper:
         self.process = self._start_process ()
 
         # Run the loop until the bus name appears, or the process dies.
-        self.process_watch_timeout = glib.timeout_add (200, self._process_watch_cb)
+        self.process_watch_timeout = GLib.timeout_add (200, self._process_watch_cb)
 
         self.loop.run ()
 
-        glib.source_remove (self.process_watch_timeout)
+        GLib.source_remove (self.process_watch_timeout)
 
     def stop (self):
         if self.available:
             # It should step out of this loop when the miner disappear from the bus
-            glib.idle_add (self._stop_process)
-            self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
+            GLib.idle_add (self._stop_process)
+            self.timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
             self.loop.run ()
             if self.timeout_id is not None:
-                glib.source_remove(self.timeout_id)
+                GLib.source_remove(self.timeout_id)
 
         log ("[%s] stop." % self.PROCESS_NAME)
         # Disconnect the signals of the next start we get duplicated messages
@@ -302,7 +302,7 @@ class StoreHelper (Helper):
                     filtered_list += [insert]
 
             if matched and in_main_loop:
-                glib.source_remove (self.graph_updated_timeout_id)
+                GLib.source_remove (self.graph_updated_timeout_id)
                 self.graph_updated_timeout_id = 0
                 self.inserts_match_function = None
                 self.loop.quit ()
@@ -319,7 +319,7 @@ class StoreHelper (Helper):
         (existing_match, self.inserts_list) = match_cb (self.inserts_list, False)
 
         if not existing_match:
-            self.graph_updated_timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT,
+            self.graph_updated_timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT,
                                                                       self._graph_updated_timeout_cb)
             self.inserts_match_function = match_cb
 
@@ -351,7 +351,7 @@ class StoreHelper (Helper):
                     filtered_list += [delete]
 
             if matched and in_main_loop:
-                glib.source_remove (self.graph_updated_timeout_id)
+                GLib.source_remove (self.graph_updated_timeout_id)
                 self.graph_updated_timeout_id = 0
                 self.deletes_match_function = None
 
@@ -364,7 +364,7 @@ class StoreHelper (Helper):
         (existing_match, self.deletes_list) = match_cb (self.deletes_list, False)
 
         if not existing_match:
-            self.graph_updated_timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT,
+            self.graph_updated_timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT,
                                                                       self._graph_updated_timeout_cb)
             self.deletes_match_function = match_cb
 
@@ -514,10 +514,10 @@ class MinerFsHelper (Helper):
                                                           dbus_interface=cfg.MINER_IFACE)
 
         # It should step out of this loop after progress changes to "Idle"
-        self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
+        self.timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
         self.loop.run ()
         if self.timeout_id is not None:
-            glib.source_remove (self.timeout_id)
+            GLib.source_remove (self.timeout_id)
 
         bus_object = self.bus.get_object (cfg.MINERFS_BUSNAME,
                                           cfg.MINERFS_OBJ_PATH)
@@ -546,12 +546,12 @@ class MinerFsHelper (Helper):
                                                           signal_name="Progress",
                                                           path=cfg.MINERFS_OBJ_PATH,
                                                           dbus_interface=cfg.MINER_IFACE)
-        self.timeout_id = glib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
+        self.timeout_id = GLib.timeout_add_seconds (REASONABLE_TIMEOUT, self._timeout_on_idle_cb)
 
         self.loop.run ()
 
         if self.timeout_id is not None:
-            glib.source_remove (self.timeout_id)
+            GLib.source_remove (self.timeout_id)
         self.bus._clean_up_signal_match (self.status_match)
 
 
diff --git a/tests/functional-tests/common/utils/system.py b/tests/functional-tests/common/utils/system.py
index 1cc2b98..8759750 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -5,7 +5,7 @@ import shutil
 import configuration as cfg
 
 from gi.repository import GObject
-import glib
+from gi.repository import GLib
 import dbus
 from dbus.mainloop.glib import DBusGMainLoop
 import time
@@ -242,7 +242,7 @@ if __name__ == "__main__":
     a = TrackerSystemAbstraction ()
     a.tracker_store_testing_start ()
     print "   started, waiting 5 sec. to stop it"
-    glib.timeout_add_seconds (5, destroy_the_world, a)
+    GLib.timeout_add_seconds (5, destroy_the_world, a)
     Gtk.main ()
 
     print "-- Starting miner-fs --"


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