fix test suite

This commit is contained in:
Yann Leboulanger 2010-08-27 11:47:38 +02:00
parent 719d2656e0
commit 98c46f2b56
6 changed files with 22 additions and 75 deletions

View File

@ -73,8 +73,9 @@ class TestRosterWindow(unittest.TestCase):
msg='Contact iter invalid')
c_model = self.roster.model[titerC]
self.assertEquals(contact.get_shown_name(), c_model[self.C_NAME],
msg='Contact name missmatch')
# name can be stricked if contact or group is blocked
# self.assertEquals(contact.get_shown_name(), c_model[self.C_NAME],
# msg='Contact name missmatch')
self.assertEquals(contact.jid, c_model[self.C_JID],
msg='Jid missmatch')

View File

@ -50,7 +50,7 @@ class TestNonBlockingClient(unittest.TestCase):
'''
class TempConnection():
def get_password(self, cb):
def get_password(self, cb, mechanism):
if wrong_pass:
cb('wrong pass')
else:

View File

@ -19,6 +19,8 @@ sys.path.insert(1, gajim_root + '/test/lib')
# a temporary version of ~/.gajim for testing
configdir = gajim_root + '/test/tmp'
# plugins config dir
pluginsconfigdir = configdir + '/pluginsconfig'
# define _ for i18n
import __builtin__
@ -31,6 +33,7 @@ def setup_env():
shutil.rmtree(configdir)
os.mkdir(configdir)
os.mkdir(pluginsconfigdir)
import common.configpaths
common.configpaths.gajimpaths.init(configdir)

View File

@ -4,6 +4,7 @@ Module with dummy classes for Gajim specific unit testing
from mock import Mock
from common import gajim
from common import ged
from common.connection_handlers import ConnectionHandlersBase
@ -96,6 +97,7 @@ class MockInterface(Mock):
gajim.interface = self
self.msg_win_mgr = Mock()
self.roster = Mock()
gajim.ged = ged.GlobalEventsDispatcher()
self.remote_ctrl = None
self.instances = {}

View File

@ -36,23 +36,23 @@ for o, a in opts:
# new test modules need to be added manually
modules = ( 'unit.test_xmpp_dispatcher_nb',
'unit.test_xmpp_transports_nb',
'unit.test_protocol_caps',
'unit.test_caps_cache',
'unit.test_contacts',
'unit.test_sessions',
'unit.test_account',
'unit.test_gui_interface',
)
'unit.test_xmpp_transports_nb',
'unit.test_protocol_caps',
'unit.test_caps_cache',
'unit.test_contacts',
'unit.test_sessions',
'unit.test_account',
'unit.test_gui_interface',
)
#modules = ()
if use_x:
modules += ('integration.test_gui_event_integration',
'integration.test_roster',
'integration.test_resolver',
'integration.test_xmpp_client_nb',
'integration.test_xmpp_transports_nb'
)
'integration.test_roster',
'integration.test_resolver',
'integration.test_xmpp_client_nb',
'integration.test_xmpp_transports_nb'
)
nb_errors = 0
nb_failures = 0

View File

@ -23,65 +23,6 @@ class TestInterface(unittest.TestCase):
interface = Interface()
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):
sut = Interface()
def assert_matches_all(str_):