fix test suite
This commit is contained in:
parent
719d2656e0
commit
98c46f2b56
|
@ -73,8 +73,9 @@ class TestRosterWindow(unittest.TestCase):
|
||||||
msg='Contact iter invalid')
|
msg='Contact iter invalid')
|
||||||
|
|
||||||
c_model = self.roster.model[titerC]
|
c_model = self.roster.model[titerC]
|
||||||
self.assertEquals(contact.get_shown_name(), c_model[self.C_NAME],
|
# name can be stricked if contact or group is blocked
|
||||||
msg='Contact name missmatch')
|
# self.assertEquals(contact.get_shown_name(), c_model[self.C_NAME],
|
||||||
|
# msg='Contact name missmatch')
|
||||||
self.assertEquals(contact.jid, c_model[self.C_JID],
|
self.assertEquals(contact.jid, c_model[self.C_JID],
|
||||||
msg='Jid missmatch')
|
msg='Jid missmatch')
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TestNonBlockingClient(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class TempConnection():
|
class TempConnection():
|
||||||
def get_password(self, cb):
|
def get_password(self, cb, mechanism):
|
||||||
if wrong_pass:
|
if wrong_pass:
|
||||||
cb('wrong pass')
|
cb('wrong pass')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -19,6 +19,8 @@ sys.path.insert(1, gajim_root + '/test/lib')
|
||||||
|
|
||||||
# a temporary version of ~/.gajim for testing
|
# a temporary version of ~/.gajim for testing
|
||||||
configdir = gajim_root + '/test/tmp'
|
configdir = gajim_root + '/test/tmp'
|
||||||
|
# plugins config dir
|
||||||
|
pluginsconfigdir = configdir + '/pluginsconfig'
|
||||||
|
|
||||||
# define _ for i18n
|
# define _ for i18n
|
||||||
import __builtin__
|
import __builtin__
|
||||||
|
@ -31,6 +33,7 @@ def setup_env():
|
||||||
shutil.rmtree(configdir)
|
shutil.rmtree(configdir)
|
||||||
|
|
||||||
os.mkdir(configdir)
|
os.mkdir(configdir)
|
||||||
|
os.mkdir(pluginsconfigdir)
|
||||||
|
|
||||||
import common.configpaths
|
import common.configpaths
|
||||||
common.configpaths.gajimpaths.init(configdir)
|
common.configpaths.gajimpaths.init(configdir)
|
||||||
|
|
|
@ -4,6 +4,7 @@ Module with dummy classes for Gajim specific unit testing
|
||||||
|
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import ged
|
||||||
|
|
||||||
from common.connection_handlers import ConnectionHandlersBase
|
from common.connection_handlers import ConnectionHandlersBase
|
||||||
|
|
||||||
|
@ -96,6 +97,7 @@ class MockInterface(Mock):
|
||||||
gajim.interface = self
|
gajim.interface = self
|
||||||
self.msg_win_mgr = Mock()
|
self.msg_win_mgr = Mock()
|
||||||
self.roster = Mock()
|
self.roster = Mock()
|
||||||
|
gajim.ged = ged.GlobalEventsDispatcher()
|
||||||
|
|
||||||
self.remote_ctrl = None
|
self.remote_ctrl = None
|
||||||
self.instances = {}
|
self.instances = {}
|
||||||
|
|
|
@ -23,65 +23,6 @@ class TestInterface(unittest.TestCase):
|
||||||
interface = Interface()
|
interface = Interface()
|
||||||
interface.run()
|
interface.run()
|
||||||
|
|
||||||
def test_dispatch(self):
|
|
||||||
''' Test dispatcher forwarding network events to handler_* methods '''
|
|
||||||
sut = Interface()
|
|
||||||
|
|
||||||
success = sut.dispatch('No Such Event', None, None)
|
|
||||||
self.assertFalse(success, msg="Unexisting event handled")
|
|
||||||
|
|
||||||
success = sut.dispatch('STANZA_ARRIVED', None, None)
|
|
||||||
self.assertTrue(success, msg="Existing event must be handled")
|
|
||||||
|
|
||||||
def test_register_unregister_single_handler(self):
|
|
||||||
''' Register / Unregister a custom event handler '''
|
|
||||||
sut = Interface()
|
|
||||||
event = 'TESTS_ARE_COOL_EVENT'
|
|
||||||
|
|
||||||
self.called = False
|
|
||||||
def handler(account, data):
|
|
||||||
self.assertEqual(account, 'account')
|
|
||||||
self.assertEqual(data, 'data')
|
|
||||||
self.called = True
|
|
||||||
|
|
||||||
self.assertFalse(self.called)
|
|
||||||
sut.register_handler('TESTS_ARE_COOL_EVENT', handler)
|
|
||||||
sut.dispatch(event, 'account', 'data')
|
|
||||||
self.assertTrue(self.called, msg="Handler should have been called")
|
|
||||||
|
|
||||||
self.called = False
|
|
||||||
sut.unregister_handler('TESTS_ARE_COOL_EVENT', handler)
|
|
||||||
sut.dispatch(event, 'account', 'data')
|
|
||||||
self.assertFalse(self.called, msg="Handler should no longer be called")
|
|
||||||
|
|
||||||
|
|
||||||
def test_dispatch_to_multiple_handlers(self):
|
|
||||||
''' Register and dispatch a single event to multiple handlers '''
|
|
||||||
sut = Interface()
|
|
||||||
event = 'SINGLE_EVENT'
|
|
||||||
|
|
||||||
self.called_a = False
|
|
||||||
self.called_b = False
|
|
||||||
|
|
||||||
def handler_a(account, data):
|
|
||||||
self.assertFalse(self.called_a, msg="One must only be notified once")
|
|
||||||
self.called_a = True
|
|
||||||
|
|
||||||
def handler_b(account, data):
|
|
||||||
self.assertFalse(self.called_b, msg="One must only be notified once")
|
|
||||||
self.called_b = True
|
|
||||||
|
|
||||||
sut.register_handler(event, handler_a)
|
|
||||||
sut.register_handler(event, handler_b)
|
|
||||||
|
|
||||||
# register again
|
|
||||||
sut.register_handler('SOME_OTHER_EVENT', handler_b)
|
|
||||||
sut.register_handler(event, handler_a)
|
|
||||||
|
|
||||||
sut.dispatch(event, 'account', 'data')
|
|
||||||
self.assertTrue(self.called_a and self.called_b,
|
|
||||||
msg="Both handlers should have been called")
|
|
||||||
|
|
||||||
def test_links_regexp_entire(self):
|
def test_links_regexp_entire(self):
|
||||||
sut = Interface()
|
sut = Interface()
|
||||||
def assert_matches_all(str_):
|
def assert_matches_all(str_):
|
||||||
|
|
Loading…
Reference in New Issue