Fix running make test
This commit is contained in:
parent
ef75e93c70
commit
5c0538a202
|
@ -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,
|
||||
|
|
|
@ -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]:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue