Mercurial > libervia-backend
comparison src/test/helpers.py @ 792:2136be5a44a8
test: define the constants JIDs and profiles as lists
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 09 Jan 2014 11:18:33 +0100 |
parents | 0cb423500fbb |
children | 52c4b755aba6 |
comparison
equal
deleted
inserted
replaced
791:23b0c949b86c | 792:2136be5a44a8 |
---|---|
102 # call FakeMemory.init and FakeMemory.addServerFeature | 102 # call FakeMemory.init and FakeMemory.addServerFeature |
103 # in your tests to change the return value of this method | 103 # in your tests to change the return value of this method |
104 return defer.succeed(jid_ if self.memory.hasServerFeature(feature, jid_, profile_key) else None) | 104 return defer.succeed(jid_ if self.memory.hasServerFeature(feature, jid_, profile_key) else None) |
105 | 105 |
106 def getClientHostJid(self, profile_key): | 106 def getClientHostJid(self, profile_key): |
107 return JID(Const.TEST_JID.host) | 107 return JID(Const.JID[0].host) |
108 | 108 |
109 | 109 |
110 class FakeBridge(object): | 110 class FakeBridge(object): |
111 """Class to simulate and test bridge calls""" | 111 """Class to simulate and test bridge calls""" |
112 | 112 |
147 profile = self.getProfileName(profile_key) | 147 profile = self.getProfileName(profile_key) |
148 return self.params[profile][(category, name)] | 148 return self.params[profile][(category, name)] |
149 | 149 |
150 def getProfileName(self, profile_key, return_profile_keys=False): | 150 def getProfileName(self, profile_key, return_profile_keys=False): |
151 if profile_key == '@DEFAULT@': | 151 if profile_key == '@DEFAULT@': |
152 return Const.TEST_PROFILE | 152 return Const.PROFILE[0] |
153 elif profile_key == '@NONE@': | 153 elif profile_key == '@NONE@': |
154 raise exceptions.ProfileNotSetError | 154 raise exceptions.ProfileNotSetError |
155 else: | 155 else: |
156 return profile_key | 156 return profile_key |
157 | 157 |
220 class FakeRosterProtocol(SatRosterProtocol): | 220 class FakeRosterProtocol(SatRosterProtocol): |
221 | 221 |
222 def __init__(self, host, parent): | 222 def __init__(self, host, parent): |
223 SatRosterProtocol.__init__(self, host) | 223 SatRosterProtocol.__init__(self, host) |
224 self.parent = parent | 224 self.parent = parent |
225 self.addItem(Const.TEST_JID) | 225 self.addItem(Const.JID[0]) |
226 | 226 |
227 def addItem(self, jid, *args, **kwargs): | 227 def addItem(self, jid, *args, **kwargs): |
228 if not args and not kwargs: | 228 if not args and not kwargs: |
229 # defaults values setted for the tests only | 229 # defaults values setted for the tests only |
230 kwargs["subscriptionTo"] = True | 230 kwargs["subscriptionTo"] = True |
239 | 239 |
240 class FakeClient(object): | 240 class FakeClient(object): |
241 def __init__(self, host): | 241 def __init__(self, host): |
242 self.host = host | 242 self.host = host |
243 self.profile = 'test_profile' | 243 self.profile = 'test_profile' |
244 self.jid = Const.TEST_JID | 244 self.jid = Const.JID[0] |
245 self.roster = FakeRosterProtocol(host, self) | 245 self.roster = FakeRosterProtocol(host, self) |
246 | 246 |
247 def send(self, obj): | 247 def send(self, obj): |
248 pass | 248 pass |
249 | 249 |