diff options
author | Stephan Erb <steve-e@h3c.de> | 2008-08-29 02:07:40 +0400 |
---|---|---|
committer | Stephan Erb <steve-e@h3c.de> | 2008-08-29 02:07:40 +0400 |
commit | a16c65873a5849da796eadf0c24cfe8a876c7312 (patch) | |
tree | 004239ade13925c5f5dfa64c30ae5f852ae90dcb /test | |
parent | d63133d765e619aef34a2fe7a269f914aba8dacb (diff) |
Small enhancements for test_roster_window.
* Make sure that contacts show up under the correct parent
* Add check support for SelfContacts
Diffstat (limited to 'test')
-rwxr-xr-x | test/lib/data.py | 8 | ||||
-rw-r--r-- | test/test_roster.py | 52 |
2 files changed, 50 insertions, 10 deletions
diff --git a/test/lib/data.py b/test/lib/data.py index 0e144290b..074a7def8 100755 --- a/test/lib/data.py +++ b/test/lib/data.py @@ -5,6 +5,9 @@ account3 = u'dingdong.org' contacts = {} contacts[account1] = { + u'myjid@'+account1: { + 'ask': None, 'groups': [], 'name': None, 'resources': {}, + 'subscription': u'both'}, u'default1@gajim.org': { 'ask': None, 'groups': [], 'name': None, 'resources': {}, 'subscription': u'both'}, @@ -19,6 +22,9 @@ contacts[account1] = { 'subscription': u'both'} } contacts[account2] = { + u'myjid@'+account2: { + 'ask': None, 'groups': [], 'name': None, 'resources': {}, + 'subscription': u'both'}, u'default3@gajim.org': { 'ask': None, 'groups': [u'GroupC',], 'name': None, 'resources': {}, 'subscription': u'both'}, @@ -46,7 +52,7 @@ contacts[account3] = { # 'ask': None, 'groups': [], 'name': None, # 'resources': {}, 'subscription': u'both'} } - +# We have contacts that are not in roster but only specified in the metadata metacontact_data = [ [{'account': account3, 'jid': u'guypsych0\\40h.com@msn.dingdong.org', diff --git a/test/test_roster.py b/test/test_roster.py index 6cba5703b..fa495ad41 100644 --- a/test/test_roster.py +++ b/test/test_roster.py @@ -22,23 +22,22 @@ class TestRosterWindow(unittest.TestCase): gajim.interface = MockInterface() self.roster = roster_window.RosterWindow() - # Please unuglify :-) self.C_NAME = roster_window.C_NAME self.C_TYPE = roster_window.C_TYPE self.C_JID = roster_window.C_JID self.C_ACCOUNT = roster_window.C_ACCOUNT - # Add after creating the window + # Add after creating RosterWindow # We want to test the filling explicitly for acc in contacts: gajim.connections[acc] = MockConnection(acc) def tearDown(self): self.roster.model.clear() - for acc in contacts: + for acc in gajim.contacts.get_accounts(): gajim.contacts.clear_contacts(acc) - # Custom assertions + ### Custom assertions def assert_all_contacts_are_in_roster(self, acc): for jid in contacts[acc]: self.assert_contact_is_in_roster(jid, acc) @@ -47,10 +46,28 @@ class TestRosterWindow(unittest.TestCase): contacts = gajim.contacts.get_contacts(account, jid) # check for all resources for contact in contacts: - iters = self.roster._get_contact_iter( - jid, account, model=self.roster.model) - self.assertTrue(len(iters) == len(contact.get_shown_groups()), - msg='Contact is not in all his groups') + iters = self.roster._get_contact_iter(jid, account, + model=self.roster.model) + + if jid != gajim.get_jid_from_account(account): + # We don't care for groups of SelfContact + self.assertTrue(len(iters) == len(contact.get_shown_groups()), + msg='Contact is not in all his groups') + + # Are we big brother? + bb_jid = None + bb_account = None + family = gajim.contacts.get_metacontacts_family(account, jid) + if family: + nearby_family, bb_jid, bb_account = \ + self.roster._get_nearby_family_and_big_brother(family, account) + + is_in_nearby_family = (jid, account) in ( + (data['jid'], data['account']) for data in nearby_family) + self.assertTrue(is_in_nearby_family, + msg='Contact not in his own nearby family') + + is_big_brother = (bb_jid, bb_account) == (jid, account) # check for each group tag for titerC in iters: @@ -66,7 +83,24 @@ class TestRosterWindow(unittest.TestCase): if not self.roster.regroup: self.assertEquals(account, c_model[self.C_ACCOUNT], msg='Account missmatch') - # TODO: Is our parent correct? (group or big b) + + # Check for correct nesting + parent_iter = self.roster.model.iter_parent(titerC) + p_model = self.roster.model[parent_iter] + if family: + if is_big_brother: + self.assertTrue(p_model[self.C_TYPE] == 'group', + msg='Big Brother is not on top') + else: + self.assertTrue(p_model[self.C_TYPE] == 'contact', + msg='Little Brother brother has no BigB') + else: + if jid == gajim.get_jid_from_account(account): + self.assertTrue(p_model[self.C_TYPE] == 'account', + msg='SelfContact is not on top') + else: + self.assertTrue(p_model[self.C_TYPE] == 'group', + msg='Contact not found in a group') def assert_group_is_in_roster(self, group, account): #TODO |