diff options
author | Yann Leboulanger <asterix@lagaule.org> | 2017-08-09 16:34:58 +0300 |
---|---|---|
committer | Yann Leboulanger <asterix@lagaule.org> | 2017-08-09 22:05:45 +0300 |
commit | b5c3b15c0fa717bbe042c5e0a1233615f3a25b2f (patch) | |
tree | 5cc0c7e422bb0d61000a9ad19a79c28a5e8efa30 /test/integration | |
parent | c57af6dade707439d6c87ddbf1502b89c32a7d0a (diff) |
Fix running tests
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/test_resolver.py | 52 | ||||
-rw-r--r-- | test/integration/test_roster.py | 10 |
2 files changed, 22 insertions, 40 deletions
diff --git a/test/integration/test_resolver.py b/test/integration/test_resolver.py index 2de36d8e8..e09d69956 100644 --- a/test/integration/test_resolver.py +++ b/test/integration/test_resolver.py @@ -5,6 +5,8 @@ import time import lib lib.setup_env() +from gi.repository import GLib + from common import resolver from mock import Mock, expectParams @@ -28,41 +30,38 @@ class TestResolver(unittest.TestCase): def setUp(self): self.idlequeue_thread = IdleQueueThread() self.idlequeue_thread.start() + self.main_context = GLib.MainContext() + self.main_context.push_thread_default() + self.main_loop = GLib.MainLoop(self.main_context) self.iq = self.idlequeue_thread.iq self._reset() self.resolver = None def tearDown(self): + self.main_context.pop_thread_default() self.idlequeue_thread.stop_thread() self.idlequeue_thread.join() def _reset(self): - self.flag = False self.expect_results = False - self.nslookup = False self.resolver = None - def testLibAsyncNSResolver(self): + def testGioResolver(self): self._reset() - if not resolver.USE_LIBASYNCNS: - print('testLibAsyncResolver: libasyncns-python not installed') - return - self.resolver = resolver.LibAsyncNSResolver() + self.resolver = resolver.GioResolver() - for name, type, expect_results in TEST_LIST: + for name, type_, expect_results in TEST_LIST: self.expect_results = expect_results - self._runLANSR(name, type) - self.flag = False + self._runGR(name, type_) - def _runLANSR(self, name, type): + def _runGR(self, name, type_): self.resolver.resolve( host = name, - type = type, + type_ = type_, on_ready = self._myonready) - while not self.flag: - time.sleep(1) - self.resolver.process() + + self.main_loop.run() def _myonready(self, name, result_set): if __name__ == '__main__': @@ -73,28 +72,11 @@ class TestResolver(unittest.TestCase): pprint('res.resolved_hosts: %s' % self.resolver.resolved_hosts) pprint('') if self.expect_results: - self.assert_(len(result_set) > 0) + self.assertTrue(len(result_set) > 0) else: - self.assert_(result_set == []) - self.flag = True - if self.nslookup: - self._testNSLR() + self.assertTrue(result_set == []) + self.main_loop.quit() - def testNSLookupResolver(self): - self._reset() - self.nslookup = True - self.resolver = resolver.NSLookupResolver(self.iq) - self.test_list = TEST_LIST - self._testNSLR() - - def _testNSLR(self): - if self.test_list == []: - return - name, type, self.expect_results = self.test_list.pop() - self.resolver.resolve( - host = name, - type = type, - on_ready = self._myonready) if __name__ == '__main__': unittest.main() diff --git a/test/integration/test_roster.py b/test/integration/test_roster.py index d81df5dd9..a45610dd6 100644 --- a/test/integration/test_roster.py +++ b/test/integration/test_roster.py @@ -20,16 +20,16 @@ class TestRosterWindow(unittest.TestCase): def setUp(self): gajim.interface = MockInterface() - self.C_NAME = roster_window.C_NAME - self.C_TYPE = roster_window.C_TYPE - self.C_JID = roster_window.C_JID - self.C_ACCOUNT = roster_window.C_ACCOUNT + self.C_NAME = roster_window.Column.NAME + self.C_TYPE = roster_window.Column.TYPE + self.C_JID = roster_window.Column.JID + self.C_ACCOUNT = roster_window.Column.ACCOUNT # Add after creating RosterWindow # We want to test the filling explicitly gajim.contacts = contacts_module.LegacyContactsAPI() gajim.connections = {} - self.roster = roster_window.RosterWindow() + self.roster = roster_window.RosterWindow(gajim.app) for acc in contacts: gajim.connections[acc] = MockConnection(acc) |