Mercurial > libervia-backend
diff src/test/helpers.py @ 999:c37a24922f27
plugin XEP_0033: fixes the server part and the tests
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 11 Apr 2014 11:02:42 +0200 |
parents | f5761534e0f3 |
children | 002ee8397208 |
line wrap: on
line diff
--- a/src/test/helpers.py Wed Apr 23 12:01:59 2014 +0200 +++ b/src/test/helpers.py Fri Apr 11 11:02:42 2014 +0200 @@ -93,7 +93,6 @@ if not skip_send: self.sent_messages.append(mess_data["to"]) self.stored_messages.append(mess_data["to"]) - pass def getClient(self, profile_key): """Convenient method to get client from profile key @@ -131,6 +130,33 @@ entry = self.getSentMessageRaw(profile_index) return entry.toXml() if entry else None + def findFeaturesSet(self, features, category=None, type_=None, jid_=None, profile_key=None): + """Call self.addFeature from your tests to change the return value. + + @return: a set of entities + """ + client = self.getClient(profile_key) + if jid_ is None: + jid_ = JID(client.jid.host) + try: + if set(features).issubset(client.features[jid_]): + return defer.succeed(set([jid_])) + except (TypeError, AttributeError, KeyError): + pass + return defer.succeed(set()) + + def addFeature(self, jid_, feature, profile_key): + """Add a feature to an entity. + + To be called from your tests when needed. + """ + client = self.getClient(profile_key) + if not hasattr(client, 'features'): + client.features = {} + if jid_ not in client.features: + client.features[jid_] = set() + client.features[jid_].add(feature) + class FakeBridge(object): """Class to simulate and test bridge calls"""