Mercurial > libervia-backend
diff src/test/helpers.py @ 1277:3a3e3014f9f8
plugin XEP-0313: first draft:
- you can already test it with d-feet but it will bug unless you apply the changeset 60dfa2f5d61f which is waiting in the branch "frontends_multi_profiles" (actually just one "assert" to comment in plugin_xep_0085.py)
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 19 Dec 2014 14:43:42 +0100 |
parents | 2308f8405ffb |
children | 41ffe2c2dddc |
line wrap: on
line diff
--- a/src/test/helpers.py Fri Dec 19 11:42:45 2014 +0100 +++ b/src/test/helpers.py Fri Dec 19 14:43:42 2014 +0100 @@ -25,12 +25,14 @@ from sat.core import exceptions from constants import Const as C from wokkel.xmppim import RosterItem +from wokkel.generic import parseXml from sat.core.xmpp import SatRosterProtocol from sat.memory.memory import Params, Memory from twisted.trial.unittest import FailTest from twisted.trial import unittest from twisted.internet import defer from twisted.words.protocols.jabber.jid import JID +from twisted.words.xish import domish from xml.etree import cElementTree as etree from collections import Counter import re @@ -355,10 +357,25 @@ self.sent = [] def send(self, obj): - """Save the sent messages to compare them later""" + """Save the sent messages to compare them later. + + @param obj (domish.Element, str or unicode): message to send + """ + if not isinstance(obj, domish.Element): + assert(isinstance(obj, str) or isinstance(obj, unicode)) + obj = parseXml(obj) + + if obj.name == 'iq': + # IQ request expects an answer, return the request itself so + # you can check if it has been well built by your plugin. + self.iqDeferreds[obj['id']].callback(obj) + self.sent.append(obj) return defer.succeed(None) + def addObserver(self, *argv): + pass + class FakeClient(object): """Tests involving more than one profile need one instance of this class per profile"""