Yann Leboulanger pushed to branch master at gajim / gajim
Commits: 5c0538a2 by Yann Leboulanger at 2017-09-15T15:11:55+02:00 Fix running make test
- - - - -
7 changed files:
- plugins/roster_buttons/plugin.py - test/integration/test_roster.py - test/lib/__init__.py - test/lib/gajim_mocks.py - test/runtests.py - test/unit/test_gui_interface.py - test/unit/test_sessions.py
Changes:
===================================== plugins/roster_buttons/plugin.py ===================================== --- a/plugins/roster_buttons/plugin.py +++ b/plugins/roster_buttons/plugin.py @@ -38,13 +38,13 @@ class RosterButtonsPlugin(GajimPlugin): def init(self): self.description = _('Adds quick action buttons to roster window.') self.GTK_BUILDER_FILE_PATH = self.local_file_path('roster_buttons.ui') - self.roster_vbox = app.interface.roster.xml.get_object('roster_vbox2') - self.show_offline_contacts_menuitem = app.interface.roster.xml.get_object('show_offline_contacts_menuitem')
self.config_dialog = None
@log_calls('RosterButtonsPlugin') def activate(self): + self.roster_vbox = app.interface.roster.xml.get_object('roster_vbox2') + self.show_offline_contacts_menuitem = app.interface.roster.xml.get_object('show_offline_contacts_menuitem') self.xml = gtk.Builder() self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
===================================== test/integration/test_roster.py ===================================== --- a/test/integration/test_roster.py +++ b/test/integration/test_roster.py @@ -35,6 +35,14 @@ class TestRosterWindow(unittest.TestCase): app.connections[acc] = MockConnection(acc) app.contacts.add_account(acc)
+ def tearDown(self): + self.roster.window.destroy() + # Clean main loop + from gi.repository import GLib + mc = GLib.main_context_default() + while mc.pending(): + mc.iteration() + ### Custom assertions def assert_all_contacts_are_in_roster(self, acc): for jid in contacts[acc]:
===================================== test/lib/__init__.py ===================================== --- a/test/lib/__init__.py +++ b/test/lib/__init__.py @@ -26,6 +26,8 @@ pluginsconfigdir = configdir + '/pluginsconfig' import builtins builtins._ = lambda x: x
+from gajim.common.contacts import LegacyContactsAPI + def setup_env(): # wipe config directory if os.path.isdir(configdir): @@ -46,6 +48,8 @@ def setup_env():
app.DATA_DIR = gajim_root + '/data' app.use_x = use_x + app.contacts = LegacyContactsAPI() + app.connections = {}
if use_x: from gajim import gtkgui_helpers
===================================== test/lib/gajim_mocks.py ===================================== --- a/test/lib/gajim_mocks.py +++ b/test/lib/gajim_mocks.py @@ -107,7 +107,7 @@ class MockInterface(Mock): self.msg_win_mgr = Mock() self.roster = Mock() app.ged = ged.GlobalEventsDispatcher() - import plugins + from gajim import plugins app.plugin_manager = plugins.PluginManager()
self.remote_ctrl = None @@ -119,7 +119,7 @@ class MockInterface(Mock): self.jabber_state_images = {'16': {}, '24': {}, '32': {}, 'opened': {}, 'closed': {}}
- import gtkgui_helpers + from gajim import gtkgui_helpers gtkgui_helpers.make_jabber_state_images() else: self.jabber_state_images = {'16': Mock(), '24': Mock(),
===================================== test/runtests.py ===================================== --- a/test/runtests.py +++ b/test/runtests.py @@ -53,8 +53,18 @@ nb_errors = 0 nb_failures = 0
for mod in modules: + print("Now running: %s" % mod) suite = unittest.defaultTestLoader.loadTestsFromName(mod) result = unittest.TextTestRunner(verbosity=verbose).run(suite) + if use_x: + # Wait 1s to be sure all timeout_add will be called before we cleanup main loop + import time + time.sleep(0.5) + # Clean main loop + from gi.repository import GLib + mc = GLib.main_context_default() + while mc.pending(): + mc.iteration() nb_errors += len(result.errors) nb_failures += len(result.failures)
===================================== test/unit/test_gui_interface.py ===================================== --- a/test/unit/test_gui_interface.py +++ b/test/unit/test_gui_interface.py @@ -16,10 +16,15 @@ app.logger = MockLogger()
from gajim.gui_interface import Interface
+from gi.repository import GLib + class TestInterface(unittest.TestCase):
def test_instantiation(self): ''' Test that we can proper initialize and do not fail on globals ''' + def close_app(): + app.app.quit() + GLib.idle_add(close_app) app.app.run()
def test_links_regexp_entire(self):
===================================== test/unit/test_sessions.py ===================================== --- a/test/unit/test_sessions.py +++ b/test/unit/test_sessions.py @@ -22,12 +22,13 @@ from gajim.roster_window import RosterWindow
from mock import Mock, expectParams from gajim_mocks import * +from data import account1
app.interface = MockInterface()
# name to use for the test account -account_name = 'test' +account_name = account1
class TestStanzaSession(unittest.TestCase): ''' Testclass for common/stanzasession.py ''' @@ -171,7 +172,7 @@ class TestChatControlSession(unittest.TestCase): jid = 'bct@necronomicorp.com' fjid = 'bct@necronomicorp.com/Gajim' msgtxt = 'testing two' - roster = RosterWindow(app.app) + app.interface.roster = RosterWindow(app.app)
sess = self.conn.sessions[jid]['123'] sess.control = MockChatControl(fjid, account_name) @@ -190,6 +191,7 @@ class TestChatControlSession(unittest.TestCase): # message was printed to the control calls = sess.control.mockGetNamedCalls('print_conversation') self.assertEqual(1, len(calls)) + app.interface.roster.window.destroy()
#def test_received_3orphaned_control(self): #'''test receiving a message when a control that doesn't have a session
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5c0538a202d3750686bd50d8d66c84637c2...
--- View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/5c0538a202d3750686bd50d8d66c84637c2... You're receiving this email because of your account on dev.gajim.org.