diff --git a/test/lib/data.py b/test/lib/data.py index 074a7def870ade720cd0187459ce86ed6fbbabbd..e74e9c01b05654d3f3a450483d7135f9f77d0bc5 100755 --- a/test/lib/data.py +++ b/test/lib/data.py @@ -6,13 +6,13 @@ account3 = u'dingdong.org' contacts = {} contacts[account1] = { u'myjid@'+account1: { - 'ask': None, 'groups': [], 'name': None, 'resources': {}, + 'ask': None, 'groups': [], 'name': None, 'resources': {}, 'subscription': u'both'}, u'default1@gajim.org': { - 'ask': None, 'groups': [], 'name': None, 'resources': {}, + 'ask': None, 'groups': [], 'name': None, 'resources': {}, 'subscription': u'both'}, u'default2@gajim.org': { - 'ask': None, 'groups': [u'GroupA',], 'name': None, 'resources': {}, + 'ask': None, 'groups': [u'GroupA',], 'name': None, 'resources': {}, 'subscription': u'both'}, u'Cool"chârßéµö@gajim.org': { 'ask': None, 'groups': [u'<Cool"chârßéµö', u'GroupB'], @@ -23,33 +23,33 @@ contacts[account1] = { } contacts[account2] = { u'myjid@'+account2: { - 'ask': None, 'groups': [], 'name': None, 'resources': {}, + 'ask': None, 'groups': [], 'name': None, 'resources': {}, 'subscription': u'both'}, u'default3@gajim.org': { - 'ask': None, 'groups': [u'GroupC',], 'name': None, 'resources': {}, + 'ask': None, 'groups': [u'GroupC',], 'name': None, 'resources': {}, 'subscription': u'both'}, u'asksubfrom@gajim.org': { 'ask': u'subscribe', 'groups': [u'GroupA',], 'name': None, 'resources': {}, 'subscription': u'from'}, u'subto@gajim.org': { - 'ask': None, 'groups': [u'GroupB'], 'name': None, 'resources': {}, + 'ask': None, 'groups': [u'GroupB'], 'name': None, 'resources': {}, 'subscription': u'to'}, u'samejid@gajim.org': { - 'ask': None, 'groups': [u'GroupA', u'GroupB'], 'name': None, + 'ask': None, 'groups': [u'GroupA', u'GroupB'], 'name': None, 'resources': {}, 'subscription': u'both'} } contacts[account3] = { #u'guypsych0\\40h.com@msn.dingdong.org': { - # 'ask': None, 'groups': [], 'name': None, 'resources': {}, + # 'ask': None, 'groups': [], 'name': None, 'resources': {}, # 'subscription': u'both'}, u'guypsych0%h.com@msn.delx.cjb.net': { 'ask': u'subscribe', 'groups': [], 'name': None, 'resources': {}, 'subscription': u'from'}, #u'guypsych0%h.com@msn.jabber.wiretrip.org': { - # 'ask': None, 'groups': [], 'name': None, 'resources': {}, + # 'ask': None, 'groups': [], 'name': None, 'resources': {}, # 'subscription': u'to'}, #u'guypsycho\\40g.com@gtalk.dingdong.org': { - # 'ask': None, 'groups': [], 'name': None, + # 'ask': None, 'groups': [], 'name': None, # 'resources': {}, 'subscription': u'both'} } # We have contacts that are not in roster but only specified in the metadata diff --git a/test/lib/mock.py b/test/lib/mock.py index 0c2b6170a17d405fb19af644cb041c5934c4edd6..0a38d41ee81f6c758584c4d9533f33e6e09d5c06 100644 --- a/test/lib/mock.py +++ b/test/lib/mock.py @@ -8,26 +8,26 @@ # This Python module and associated files are released under the FreeBSD # license. Essentially, you can do what you like with it except pretend you wrote # it yourself. -# -# +# +# # Copyright (c) 2005, Dave Kirby -# +# # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * Neither the name of this library nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -38,7 +38,7 @@ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# +# # mock@thedeveloperscoach.com @@ -90,7 +90,7 @@ class Mock: if retMethod not in self.realClassMethods: raise MockInterfaceError("Return value supplied for method '%s' that was not in the original class" % retMethod) self._setupSubclassMethodInterceptors() - + def _setupSubclassMethodInterceptors(self): methods = inspect.getmembers(self.__class__,inspect.isroutine) baseMethods = dict(inspect.getmembers(Mock, inspect.ismethod)) @@ -99,13 +99,13 @@ class Mock: # Don't record calls to methods of Mock base class. if not name in baseMethods: self.__dict__[name] = MockCallable(name, self, handcrafted=True) - + def __getattr__(self, name): return MockCallable(name, self) - + def mockAddReturnValues(self, **methodReturnValues ): self.mockReturnValues.update(methodReturnValues) - + def mockSetExpectation(self, name, testFn, after=0, until=0): self.mockExpectations.setdefault(name, []).append((testFn,after,until)) @@ -134,7 +134,7 @@ class Mock: numPosCallParams = 1 + len(callParams) if numPosCallParams > len(args) and not varargs: - raise MockInterfaceError("Original %s() takes at most %s arguments (%s given)" % + raise MockInterfaceError("Original %s() takes at most %s arguments (%s given)" % (name, len(args), numPosCallParams)) # Get the number of positional arguments that appear in the call, @@ -220,7 +220,7 @@ class MockCall: def getName(self): return self.name - + #pretty-print the method call def __str__(self): s = self.name + "(" @@ -310,13 +310,13 @@ class ReturnValuesBase: class ReturnValues(ReturnValuesBase): def __init__(self, *values): self.iter = iter(values) - + class ReturnIterator(ReturnValuesBase): def __init__(self, iterator): self.iter = iter(iterator) - + def expectParams(*params, **keywords): '''check that the callObj is called with specified params and keywords ''' @@ -332,7 +332,7 @@ def expectAfter(*methods): calledMethods = [method.getName() for method in mockObj.mockGetAllCalls()] #skip last entry, since that is the current call calledMethods = calledMethods[:-1] - for method in methods: + for method in methods: if method not in calledMethods: return False return True @@ -430,17 +430,17 @@ def IS(instance): def ISINSTANCE(class_): def testFn(param): - return isinstance(param, class_) + return isinstance(param, class_) return testFn def ISSUBCLASS(class_): def testFn(param): - return issubclass(param, class_) + return issubclass(param, class_) return testFn def CONTAINS(val): def testFn(param): - return val in param + return val in param return testFn def IN(container): diff --git a/test/test_roster.py b/test/test_roster.py index fa495ad419f24678f05d220d5a2dede19c00e00d..421148c83128048baecb4beda3ba42242e54429b 100644 --- a/test/test_roster.py +++ b/test/test_roster.py @@ -46,9 +46,9 @@ 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, + 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()), @@ -61,7 +61,7 @@ class TestRosterWindow(unittest.TestCase): 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,