Fix running make test
This commit is contained in:
parent
ef75e93c70
commit
5c0538a202
|
@ -38,13 +38,13 @@ class RosterButtonsPlugin(GajimPlugin):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.description = _('Adds quick action buttons to roster window.')
|
self.description = _('Adds quick action buttons to roster window.')
|
||||||
self.GTK_BUILDER_FILE_PATH = self.local_file_path('roster_buttons.ui')
|
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
|
self.config_dialog = None
|
||||||
|
|
||||||
@log_calls('RosterButtonsPlugin')
|
@log_calls('RosterButtonsPlugin')
|
||||||
def activate(self):
|
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 = gtk.Builder()
|
||||||
self.xml.set_translation_domain('gajim_plugins')
|
self.xml.set_translation_domain('gajim_plugins')
|
||||||
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
|
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
|
||||||
|
|
|
@ -35,6 +35,14 @@ class TestRosterWindow(unittest.TestCase):
|
||||||
app.connections[acc] = MockConnection(acc)
|
app.connections[acc] = MockConnection(acc)
|
||||||
app.contacts.add_account(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
|
### Custom assertions
|
||||||
def assert_all_contacts_are_in_roster(self, acc):
|
def assert_all_contacts_are_in_roster(self, acc):
|
||||||
for jid in contacts[acc]:
|
for jid in contacts[acc]:
|
||||||
|
|
|
@ -26,6 +26,8 @@ pluginsconfigdir = configdir + '/pluginsconfig'
|
||||||
import builtins
|
import builtins
|
||||||
builtins._ = lambda x: x
|
builtins._ = lambda x: x
|
||||||
|
|
||||||
|
from gajim.common.contacts import LegacyContactsAPI
|
||||||
|
|
||||||
def setup_env():
|
def setup_env():
|
||||||
# wipe config directory
|
# wipe config directory
|
||||||
if os.path.isdir(configdir):
|
if os.path.isdir(configdir):
|
||||||
|
@ -46,6 +48,8 @@ def setup_env():
|
||||||
|
|
||||||
app.DATA_DIR = gajim_root + '/data'
|
app.DATA_DIR = gajim_root + '/data'
|
||||||
app.use_x = use_x
|
app.use_x = use_x
|
||||||
|
app.contacts = LegacyContactsAPI()
|
||||||
|
app.connections = {}
|
||||||
|
|
||||||
if use_x:
|
if use_x:
|
||||||
from gajim import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
|
|
|
@ -107,7 +107,7 @@ class MockInterface(Mock):
|
||||||
self.msg_win_mgr = Mock()
|
self.msg_win_mgr = Mock()
|
||||||
self.roster = Mock()
|
self.roster = Mock()
|
||||||
app.ged = ged.GlobalEventsDispatcher()
|
app.ged = ged.GlobalEventsDispatcher()
|
||||||
import plugins
|
from gajim import plugins
|
||||||
app.plugin_manager = plugins.PluginManager()
|
app.plugin_manager = plugins.PluginManager()
|
||||||
|
|
||||||
self.remote_ctrl = None
|
self.remote_ctrl = None
|
||||||
|
@ -119,7 +119,7 @@ class MockInterface(Mock):
|
||||||
self.jabber_state_images = {'16': {}, '24': {}, '32': {},
|
self.jabber_state_images = {'16': {}, '24': {}, '32': {},
|
||||||
'opened': {}, 'closed': {}}
|
'opened': {}, 'closed': {}}
|
||||||
|
|
||||||
import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
gtkgui_helpers.make_jabber_state_images()
|
gtkgui_helpers.make_jabber_state_images()
|
||||||
else:
|
else:
|
||||||
self.jabber_state_images = {'16': Mock(), '24': Mock(),
|
self.jabber_state_images = {'16': Mock(), '24': Mock(),
|
||||||
|
|
|
@ -53,8 +53,18 @@ nb_errors = 0
|
||||||
nb_failures = 0
|
nb_failures = 0
|
||||||
|
|
||||||
for mod in modules:
|
for mod in modules:
|
||||||
|
print("Now running: %s" % mod)
|
||||||
suite = unittest.defaultTestLoader.loadTestsFromName(mod)
|
suite = unittest.defaultTestLoader.loadTestsFromName(mod)
|
||||||
result = unittest.TextTestRunner(verbosity=verbose).run(suite)
|
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_errors += len(result.errors)
|
||||||
nb_failures += len(result.failures)
|
nb_failures += len(result.failures)
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,15 @@ app.logger = MockLogger()
|
||||||
|
|
||||||
from gajim.gui_interface import Interface
|
from gajim.gui_interface import Interface
|
||||||
|
|
||||||
|
from gi.repository import GLib
|
||||||
|
|
||||||
class TestInterface(unittest.TestCase):
|
class TestInterface(unittest.TestCase):
|
||||||
|
|
||||||
def test_instantiation(self):
|
def test_instantiation(self):
|
||||||
''' Test that we can proper initialize and do not fail on globals '''
|
''' 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()
|
app.app.run()
|
||||||
|
|
||||||
def test_links_regexp_entire(self):
|
def test_links_regexp_entire(self):
|
||||||
|
|
|
@ -22,12 +22,13 @@ from gajim.roster_window import RosterWindow
|
||||||
|
|
||||||
from mock import Mock, expectParams
|
from mock import Mock, expectParams
|
||||||
from gajim_mocks import *
|
from gajim_mocks import *
|
||||||
|
from data import account1
|
||||||
|
|
||||||
app.interface = MockInterface()
|
app.interface = MockInterface()
|
||||||
|
|
||||||
|
|
||||||
# name to use for the test account
|
# name to use for the test account
|
||||||
account_name = 'test'
|
account_name = account1
|
||||||
|
|
||||||
class TestStanzaSession(unittest.TestCase):
|
class TestStanzaSession(unittest.TestCase):
|
||||||
''' Testclass for common/stanzasession.py '''
|
''' Testclass for common/stanzasession.py '''
|
||||||
|
@ -171,7 +172,7 @@ class TestChatControlSession(unittest.TestCase):
|
||||||
jid = 'bct@necronomicorp.com'
|
jid = 'bct@necronomicorp.com'
|
||||||
fjid = 'bct@necronomicorp.com/Gajim'
|
fjid = 'bct@necronomicorp.com/Gajim'
|
||||||
msgtxt = 'testing two'
|
msgtxt = 'testing two'
|
||||||
roster = RosterWindow(app.app)
|
app.interface.roster = RosterWindow(app.app)
|
||||||
|
|
||||||
sess = self.conn.sessions[jid]['123']
|
sess = self.conn.sessions[jid]['123']
|
||||||
sess.control = MockChatControl(fjid, account_name)
|
sess.control = MockChatControl(fjid, account_name)
|
||||||
|
@ -190,6 +191,7 @@ class TestChatControlSession(unittest.TestCase):
|
||||||
# message was printed to the control
|
# message was printed to the control
|
||||||
calls = sess.control.mockGetNamedCalls('print_conversation')
|
calls = sess.control.mockGetNamedCalls('print_conversation')
|
||||||
self.assertEqual(1, len(calls))
|
self.assertEqual(1, len(calls))
|
||||||
|
app.interface.roster.window.destroy()
|
||||||
|
|
||||||
#def test_received_3orphaned_control(self):
|
#def test_received_3orphaned_control(self):
|
||||||
#'''test receiving a message when a control that doesn't have a session
|
#'''test receiving a message when a control that doesn't have a session
|
||||||
|
|
Loading…
Reference in New Issue