Skip to content
Snippets Groups Projects
Commit 83d9ef49 authored by Brendan Taylor's avatar Brendan Taylor
Browse files

a script for running all the tests

parent ab70491d
No related branches found
No related tags found
No related merge requests found
...@@ -69,7 +69,7 @@ def __init__(self, *args): ...@@ -69,7 +69,7 @@ def __init__(self, *args):
class MockLogger(Mock): class MockLogger(Mock):
def __init__(self): def __init__(self):
Mock.__init__(self, {'write': None}) Mock.__init__(self, {'write': None, 'get_transports_type': {}})
class MockContact(Mock): class MockContact(Mock):
def __nonzero__(self): def __nonzero__(self):
......
#!/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:
...@@ -5,15 +5,10 @@ ...@@ -5,15 +5,10 @@
testlib.setup_env() testlib.setup_env()
from common import gajim from common import gajim
from common import xmpp
from common.caps import CapsCache
from mock import Mock
from gajim import Interface from gajim import Interface
gajim.logger = Mock() from mocks import MockLogger
gajim.logger = MockLogger()
Interface() Interface()
......
...@@ -21,7 +21,7 @@ class TestRosterWindow(unittest.TestCase): ...@@ -21,7 +21,7 @@ class TestRosterWindow(unittest.TestCase):
def setUp(self): def setUp(self):
gajim.interface = MockInterface() gajim.interface = MockInterface()
self.roster = roster_window.RosterWindow() self.roster = roster_window.RosterWindow()
# Please unuglify :-) # Please unuglify :-)
self.C_NAME = roster_window.C_NAME self.C_NAME = roster_window.C_NAME
self.C_TYPE = roster_window.C_TYPE self.C_TYPE = roster_window.C_TYPE
...@@ -52,7 +52,7 @@ def assert_contact_is_in_roster(self, jid, account): ...@@ -52,7 +52,7 @@ def assert_contact_is_in_roster(self, jid, account):
self.assertTrue(len(iters) == len(contact.get_shown_groups()), self.assertTrue(len(iters) == len(contact.get_shown_groups()),
msg='Contact is not in all his groups') msg='Contact is not in all his groups')
# check for each group tag # check for each group tag
for titerC in iters: for titerC in iters:
self.assertTrue(self.roster.model.iter_is_valid(titerC), self.assertTrue(self.roster.model.iter_is_valid(titerC),
msg='Contact iter invalid') msg='Contact iter invalid')
...@@ -67,7 +67,7 @@ def assert_contact_is_in_roster(self, jid, account): ...@@ -67,7 +67,7 @@ def assert_contact_is_in_roster(self, jid, account):
self.assertEquals(account, c_model[self.C_ACCOUNT], self.assertEquals(account, c_model[self.C_ACCOUNT],
msg='Account missmatch') msg='Account missmatch')
# TODO: Is our parent correct? (group or big b) # TODO: Is our parent correct? (group or big b)
def assert_group_is_in_roster(self, group, account): def assert_group_is_in_roster(self, group, account):
#TODO #TODO
pass pass
...@@ -80,7 +80,7 @@ def assert_account_is_in_roster(self, acc): ...@@ -80,7 +80,7 @@ def assert_account_is_in_roster(self, acc):
acc_model = self.roster.model[titerA] acc_model = self.roster.model[titerA]
self.assertEquals(acc_model[self.C_TYPE], 'account', self.assertEquals(acc_model[self.C_TYPE], 'account',
msg='No account found') msg='No account found')
if not self.roster.regroup: if not self.roster.regroup:
self.assertEquals(acc_model[self.C_ACCOUNT], acc, self.assertEquals(acc_model[self.C_ACCOUNT], acc,
msg='Account not found') msg='Account not found')
...@@ -88,7 +88,7 @@ def assert_account_is_in_roster(self, acc): ...@@ -88,7 +88,7 @@ def assert_account_is_in_roster(self, acc):
self_jid = gajim.get_jid_from_account(acc) self_jid = gajim.get_jid_from_account(acc)
self.assertEquals(acc_model[self.C_JID], self_jid, self.assertEquals(acc_model[self.C_JID], self_jid,
msg='Account JID not found in account row') msg='Account JID not found in account row')
def assert_model_is_in_sync(self): def assert_model_is_in_sync(self):
#TODO: check that iter_n_children returns the correct numbers #TODO: check that iter_n_children returns the correct numbers
pass pass
...@@ -97,18 +97,18 @@ def assert_model_is_in_sync(self): ...@@ -97,18 +97,18 @@ def assert_model_is_in_sync(self):
def test_fill_contacts_and_groups_dicts(self): def test_fill_contacts_and_groups_dicts(self):
for acc in contacts: for acc in contacts:
self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc) self.roster.fill_contacts_and_groups_dicts(contacts[acc], acc)
for jid in contacts[acc]: for jid in contacts[acc]:
instances = gajim.contacts.get_contacts(acc, jid) instances = gajim.contacts.get_contacts(acc, jid)
# Created a contact for each single jid? # Created a contact for each single jid?
self.assertTrue(len(instances) == 1) self.assertTrue(len(instances) == 1)
# Contacts kept their info # Contacts kept their info
contact = instances[0] contact = instances[0]
self.assertEquals(contact.groups, contacts[acc][jid]['groups'], self.assertEquals(contact.groups, contacts[acc][jid]['groups'],
msg='Group Missmatch') msg='Group Missmatch')
groups = contacts[acc][jid]['groups'] or ['General',] groups = contacts[acc][jid]['groups'] or ['General',]
# cleanup # cleanup
...@@ -123,9 +123,9 @@ def test_fill_roster_model(self): ...@@ -123,9 +123,9 @@ def test_fill_roster_model(self):
self.roster.add_account(acc) self.roster.add_account(acc)
self.assert_account_is_in_roster(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_all_contacts_are_in_roster(acc)
self.assert_model_is_in_sync() self.assert_model_is_in_sync()
...@@ -166,6 +166,6 @@ def test_connect_new_metacontact(self): ...@@ -166,6 +166,6 @@ def test_connect_new_metacontact(self):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
# vim: se ts=3: # vim: se ts=3:
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') 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 # a temporary version of ~/.gajim for testing
configdir = gajim_root + '/test/tmp' configdir = gajim_root + '/test/tmp'
...@@ -34,4 +35,4 @@ def setup_env(): ...@@ -34,4 +35,4 @@ def setup_env():
import gtkgui_helpers import gtkgui_helpers
gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade' gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade'
# vim: se ts=3: # vim: se ts=3:
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment