plugin XEP_0033: fixes the server part and the tests

This commit is contained in:
souliane 2014-04-11 11:02:42 +02:00
commit f0fa9b699d

View file

@ -93,7 +93,6 @@ class FakeSAT(object):
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 @@ class FakeSAT(object):
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"""