a script for running all the tests

This commit is contained in:
Brendan Taylor 2008-08-08 23:53:44 +00:00
parent ab70491d56
commit 83d9ef49a3
5 changed files with 33 additions and 21 deletions

View File

@ -69,7 +69,7 @@ class MockInterface(Mock):
class MockLogger(Mock):
def __init__(self):
Mock.__init__(self, {'write': None})
Mock.__init__(self, {'write': None, 'get_transports_type': {}})
class MockContact(Mock):
def __nonzero__(self):

16
test/runtests.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
import unittest
# new test modules need to be added manually
modules = ( 'test_caps',
'test_dispatcher_nb',
'test_misc_interface',
'test_roster',
'test_sessions',
)
for mod in modules:
suite = unittest.defaultTestLoader.loadTestsFromName(mod)
unittest.TextTestRunner(verbosity=1).run(suite)
# vim: se ts=3:

View File

@ -5,15 +5,10 @@ import testlib
testlib.setup_env()
from common import gajim
from common import xmpp
from common.caps import CapsCache
from mock import Mock
from gajim import Interface
gajim.logger = Mock()
from mocks import MockLogger
gajim.logger = MockLogger()
Interface()

View File

@ -21,7 +21,7 @@ class TestRosterWindow(unittest.TestCase):
def setUp(self):
gajim.interface = MockInterface()
self.roster = roster_window.RosterWindow()
# Please unuglify :-)
self.C_NAME = roster_window.C_NAME
self.C_TYPE = roster_window.C_TYPE
@ -52,7 +52,7 @@ class TestRosterWindow(unittest.TestCase):
self.assertTrue(len(iters) == len(contact.get_shown_groups()),
msg='Contact is not in all his groups')
# check for each group tag
# check for each group tag
for titerC in iters:
self.assertTrue(self.roster.model.iter_is_valid(titerC),
msg='Contact iter invalid')
@ -67,7 +67,7 @@ class TestRosterWindow(unittest.TestCase):
self.assertEquals(account, c_model[self.C_ACCOUNT],
msg='Account missmatch')
# TODO: Is our parent correct? (group or big b)
def assert_group_is_in_roster(self, group, account):
#TODO
pass
@ -80,7 +80,7 @@ class TestRosterWindow(unittest.TestCase):
acc_model = self.roster.model[titerA]
self.assertEquals(acc_model[self.C_TYPE], 'account',
msg='No account found')
if not self.roster.regroup:
self.assertEquals(acc_model[self.C_ACCOUNT], acc,
msg='Account not found')
@ -88,7 +88,7 @@ class TestRosterWindow(unittest.TestCase):
self_jid = gajim.get_jid_from_account(acc)
self.assertEquals(acc_model[self.C_JID], self_jid,
msg='Account JID not found in account row')
def assert_model_is_in_sync(self):
#TODO: check that iter_n_children returns the correct numbers
pass
@ -97,18 +97,18 @@ class TestRosterWindow(unittest.TestCase):
def test_fill_contacts_and_groups_dicts(self):
for acc in contacts:
self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc)
for jid in contacts[acc]:
instances = gajim.contacts.get_contacts(acc, jid)
# Created a contact for each single jid?
self.assertTrue(len(instances) == 1)
# Contacts kept their info
contact = instances[0]
self.assertEquals(contact.groups, contacts[acc][jid]['groups'],
msg='Group Missmatch')
groups = contacts[acc][jid]['groups'] or ['General',]
# cleanup
@ -123,9 +123,9 @@ class TestRosterWindow(unittest.TestCase):
self.roster.add_account(acc)
self.assert_account_is_in_roster(acc)
self.roster.add_account_contacts(acc)
self.roster.add_account_contacts(acc)
self.assert_all_contacts_are_in_roster(acc)
self.assert_model_is_in_sync()
@ -166,6 +166,6 @@ class TestRosterWindowMetaContacts(TestRosterWindowRegrouped):
if __name__ == '__main__':
unittest.main()
unittest.main()
# vim: se ts=3:

View File

@ -3,7 +3,8 @@ import os.path
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
sys.path.append(gajim_root + '/src')
# look for modules in the CWD, then gajim/src, then everywhere else
sys.path.insert(1, gajim_root + '/src')
# a temporary version of ~/.gajim for testing
configdir = gajim_root + '/test/tmp'
@ -34,4 +35,4 @@ def setup_env():
import gtkgui_helpers
gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade'
# vim: se ts=3:
# vim: se ts=3: