summaryrefslogtreecommitdiff
path: root/tests/functional-tests
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2014-07-20 12:12:18 +0100
committerSam Thursfield <sam@afuera.me.uk>2014-07-31 14:16:26 +0100
commite9b3bb58b94334c9d2095dc69bd8795b02b74f02 (patch)
tree044e4b19af9c3e648d8d12b09dc3e4d141f8148c /tests/functional-tests
parent8e72972b6b55fad3e6c4ff6421e7b4feae71b2ec (diff)
downloadtracker-e9b3bb58b94334c9d2095dc69bd8795b02b74f02.tar.gz
functional-tests: Replace use of PyGObject and PyGTK with PyGI
If we do 'import gobject' anywhere then we cannot use the new GObject-introspection based Python bindings, because they conflict. This change means the functional tests can now use PyGI, instead of the deprecated and out-of-date PyGObject and PyGTK. Note that the dbus-python bindings are still widely used in the functional-tests. These work fine but are deprecated. We should switch to using GDBus through GObject-introspection instead when possible.
Diffstat (limited to 'tests/functional-tests')
-rwxr-xr-xtests/functional-tests/09-concurrent-query.py6
-rwxr-xr-xtests/functional-tests/10-sqlite-misused.py8
-rwxr-xr-xtests/functional-tests/11-sqlite-batch-misused.py8
-rwxr-xr-xtests/functional-tests/13-threaded-store.py10
-rwxr-xr-xtests/functional-tests/14-signals.py10
-rwxr-xr-xtests/functional-tests/301-miner-resource-removal.py2
-rw-r--r--tests/functional-tests/common/utils/helpers.py32
-rw-r--r--tests/functional-tests/common/utils/system.py10
-rw-r--r--tests/functional-tests/fts-tc.py4
-rw-r--r--tests/functional-tests/mass-storage-mode.py4
10 files changed, 47 insertions, 47 deletions
diff --git a/tests/functional-tests/09-concurrent-query.py b/tests/functional-tests/09-concurrent-query.py
index 4cc626e14..652d428d3 100755
--- a/tests/functional-tests/09-concurrent-query.py
+++ b/tests/functional-tests/09-concurrent-query.py
@@ -26,7 +26,7 @@ import time
import random
import commands
import signal
-import gobject
+from gi.repository import GObject
from dbus.mainloop.glib import DBusGMainLoop
from common.utils import configuration as cfg
@@ -43,7 +43,7 @@ class TestConcurrentQuery (CommonTrackerStoreTest):
holding those queries
"""
def setUp (self):
- self.main_loop = gobject.MainLoop ()
+ self.main_loop = GObject.MainLoop ()
self.mock_data_insert ()
self.finish_counter = 0
@@ -81,7 +81,7 @@ class TestConcurrentQuery (CommonTrackerStoreTest):
error_handler=self.error_handler)
# Safeguard of 50 seconds. The last reply should quit the loop
- gobject.timeout_add_seconds (60, self.timeout_cb)
+ GObject.timeout_add_seconds (60, self.timeout_cb)
self.main_loop.run ()
def reply_cb (self, results):
diff --git a/tests/functional-tests/10-sqlite-misused.py b/tests/functional-tests/10-sqlite-misused.py
index 0e7f1ec72..f1b8ca72b 100755
--- a/tests/functional-tests/10-sqlite-misused.py
+++ b/tests/functional-tests/10-sqlite-misused.py
@@ -22,7 +22,7 @@ Test the query while importing at the same time. This was raising
some SQLITE_MISUSED errors before.
"""
import os, dbus
-import gobject
+from gi.repository import GObject
from dbus.mainloop.glib import DBusGMainLoop
from common.utils import configuration as cfg
@@ -35,7 +35,7 @@ class TestSqliteMisused (CommonTrackerStoreTest):
Send queries while importing files (in .ttl directory)
"""
def setUp (self):
- self.main_loop = gobject.MainLoop ()
+ self.main_loop = GObject.MainLoop ()
self.files_counter = 0
def test_queries_while_import (self):
@@ -49,9 +49,9 @@ class TestSqliteMisused (CommonTrackerStoreTest):
reply_handler=self.loaded_success_cb,
error_handler=self.loaded_failed_cb)
- gobject.timeout_add_seconds (2, self.run_a_query)
+ GObject.timeout_add_seconds (2, self.run_a_query)
# Safeguard of 60 seconds. The last reply should quit the loop
- gobject.timeout_add_seconds (60, self.timeout_cb)
+ GObject.timeout_add_seconds (60, self.timeout_cb)
self.main_loop.run ()
def run_a_query (self):
diff --git a/tests/functional-tests/11-sqlite-batch-misused.py b/tests/functional-tests/11-sqlite-batch-misused.py
index be24044b8..230fe9970 100755
--- a/tests/functional-tests/11-sqlite-batch-misused.py
+++ b/tests/functional-tests/11-sqlite-batch-misused.py
@@ -22,7 +22,7 @@ Test the query while running BatchSparqlUpdate at the same time. This was raisin
some SQLITE_MISUSED errors before.
"""
import os, dbus
-import gobject
+from gi.repository import GObject
from dbus.mainloop.glib import DBusGMainLoop
from common.utils import configuration as cfg
@@ -40,7 +40,7 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
to configure properly the environment
"""
def setUp (self):
- self.main_loop = gobject.MainLoop ()
+ self.main_loop = GObject.MainLoop ()
self.batch_counter = 0
def test_queries_while_batch_insert (self):
@@ -72,9 +72,9 @@ class TestSqliteBatchMisused (CommonTrackerStoreTest):
self.batch_counter += 1
- gobject.timeout_add_seconds (2, self.run_a_query)
+ GObject.timeout_add_seconds (2, self.run_a_query)
# Safeguard of 60 seconds. The last reply should quit the loop
- gobject.timeout_add_seconds (60, self.timeout_cb)
+ GObject.timeout_add_seconds (60, self.timeout_cb)
self.main_loop.run ()
def run_a_query (self):
diff --git a/tests/functional-tests/13-threaded-store.py b/tests/functional-tests/13-threaded-store.py
index 7caddeb33..bda0adcd3 100755
--- a/tests/functional-tests/13-threaded-store.py
+++ b/tests/functional-tests/13-threaded-store.py
@@ -22,8 +22,8 @@ Test that the threads in the daemon are working:
A very long query shouldn't block smaller queries.
"""
import os, dbus
-import gobject
-import glib
+from gi.repository import GObject
+from gi.repository import GLib
import time
from dbus.mainloop.glib import DBusGMainLoop
@@ -46,7 +46,7 @@ class TestThreadedStore (CommonTrackerStoreTest):
Reported in bug NB#183499
"""
def setUp (self):
- self.main_loop = gobject.MainLoop ()
+ self.main_loop = GObject.MainLoop ()
self.simple_queries_counter = AMOUNT_SIMPLE_QUERIES
self.simple_queries_answers = 0
@@ -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 c999f050b..19b01fa8c 100755
--- a/tests/functional-tests/14-signals.py
+++ b/tests/functional-tests/14-signals.py
@@ -27,8 +27,8 @@ import unittest2 as ut
from common.utils.storetest import CommonTrackerStoreTest as CommonTrackerStoreTest
from common.utils import configuration as cfg
-import gobject
-import glib
+from gi.repository import GObject
+from gi.repository import GLib
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import time
@@ -49,7 +49,7 @@ class TrackerStoreSignalsTests (CommonTrackerStoreTest):
"""
def setUp (self):
self.clean_up_list = []
- self.loop = gobject.MainLoop()
+ self.loop = GObject.MainLoop()
dbus_loop = DBusGMainLoop(set_as_default=True)
self.bus = dbus.SessionBus (dbus_loop)
self.timeout_id = 0
@@ -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 edf48b840..2394f3775 100755
--- a/tests/functional-tests/301-miner-resource-removal.py
+++ b/tests/functional-tests/301-miner-resource-removal.py
@@ -28,7 +28,7 @@ from common.utils.helpers import MinerFsHelper, StoreHelper, ExtractorHelper, lo
from common.utils.system import TrackerSystemAbstraction
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 0d6cb7968..3a43cc9bb 100644
--- a/tests/functional-tests/common/utils/helpers.py
+++ b/tests/functional-tests/common/utils/helpers.py
@@ -18,8 +18,8 @@
# 02110-1301, USA.
#
import dbus
-import glib
-import gobject
+from gi.repository import GLib
+from gi.repository import GObject
import commands
import os
import signal
@@ -62,7 +62,7 @@ class Helper:
if self.bus is not None:
return
- self.loop = gobject.MainLoop ()
+ self.loop = GObject.MainLoop ()
dbus_loop = DBusGMainLoop (set_as_default=True)
self.bus = dbus.SessionBus (dbus_loop)
@@ -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)
@@ -541,12 +541,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 9636b8cbd..855fa4909 100644
--- a/tests/functional-tests/common/utils/system.py
+++ b/tests/functional-tests/common/utils/system.py
@@ -4,8 +4,8 @@ import subprocess
import shutil
import configuration as cfg
-import gobject
-import glib
+from gi.repository import GObject
+from gi.repository import GLib
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import time
@@ -231,14 +231,14 @@ if __name__ == "__main__":
def destroy_the_world (a):
a.tracker_store_testing_stop ()
print " stopped"
- gtk.main_quit()
+ Gtk.main_quit()
print "-- Starting store --"
a = TrackerSystemAbstraction ()
a.tracker_store_testing_start ()
print " started, waiting 5 sec. to stop it"
- glib.timeout_add_seconds (5, destroy_the_world, a)
- gtk.main ()
+ GLib.timeout_add_seconds (5, destroy_the_world, a)
+ Gtk.main ()
print "-- Starting miner-fs --"
b = TrackerMinerFsLifeCycle ()
diff --git a/tests/functional-tests/fts-tc.py b/tests/functional-tests/fts-tc.py
index 025dcc1c6..1c5686dd3 100644
--- a/tests/functional-tests/fts-tc.py
+++ b/tests/functional-tests/fts-tc.py
@@ -27,7 +27,7 @@ import random
import commands
import configuration
from dbus.mainloop.glib import DBusGMainLoop
-import gobject
+from gi.repository import GObject
import shutil
from subprocess import Popen,PIPE
@@ -115,7 +115,7 @@ class TestUpdate (unittest.TestCase):
self.miner=dbus.Interface (miner_obj,dbus_interface=MINER_IFACE)
- self.loop = gobject.MainLoop()
+ self.loop = GObject.MainLoop()
self.dbus_loop = DBusGMainLoop(set_as_default=True)
self.bus = dbus.SessionBus (self.dbus_loop)
diff --git a/tests/functional-tests/mass-storage-mode.py b/tests/functional-tests/mass-storage-mode.py
index fe19a8af0..0844b21b2 100644
--- a/tests/functional-tests/mass-storage-mode.py
+++ b/tests/functional-tests/mass-storage-mode.py
@@ -25,7 +25,7 @@ import random
import commands
import configuration
from dbus.mainloop.glib import DBusGMainLoop
-import gobject
+from gi.repository import GObject
import shutil
TRACKER = 'org.freedesktop.Tracker1'
@@ -95,7 +95,7 @@ class TestUpdate (unittest.TestCase):
self.miner=dbus.Interface (miner_obj,dbus_interface=MINER_IFACE)
- self.loop = gobject.MainLoop()
+ self.loop = GObject.MainLoop()
self.dbus_loop = DBusGMainLoop(set_as_default=True)
self.bus = dbus.SessionBus (self.dbus_loop)