comparison 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
comparison
equal deleted inserted replaced
1276:56adf73bedeb 1277:3a3e3014f9f8
23 log_config.satConfigure() 23 log_config.satConfigure()
24 24
25 from sat.core import exceptions 25 from sat.core import exceptions
26 from constants import Const as C 26 from constants import Const as C
27 from wokkel.xmppim import RosterItem 27 from wokkel.xmppim import RosterItem
28 from wokkel.generic import parseXml
28 from sat.core.xmpp import SatRosterProtocol 29 from sat.core.xmpp import SatRosterProtocol
29 from sat.memory.memory import Params, Memory 30 from sat.memory.memory import Params, Memory
30 from twisted.trial.unittest import FailTest 31 from twisted.trial.unittest import FailTest
31 from twisted.trial import unittest 32 from twisted.trial import unittest
32 from twisted.internet import defer 33 from twisted.internet import defer
33 from twisted.words.protocols.jabber.jid import JID 34 from twisted.words.protocols.jabber.jid import JID
35 from twisted.words.xish import domish
34 from xml.etree import cElementTree as etree 36 from xml.etree import cElementTree as etree
35 from collections import Counter 37 from collections import Counter
36 import re 38 import re
37 39
38 40
353 355
354 def __init__(self): 356 def __init__(self):
355 self.sent = [] 357 self.sent = []
356 358
357 def send(self, obj): 359 def send(self, obj):
358 """Save the sent messages to compare them later""" 360 """Save the sent messages to compare them later.
361
362 @param obj (domish.Element, str or unicode): message to send
363 """
364 if not isinstance(obj, domish.Element):
365 assert(isinstance(obj, str) or isinstance(obj, unicode))
366 obj = parseXml(obj)
367
368 if obj.name == 'iq':
369 # IQ request expects an answer, return the request itself so
370 # you can check if it has been well built by your plugin.
371 self.iqDeferreds[obj['id']].callback(obj)
372
359 self.sent.append(obj) 373 self.sent.append(obj)
360 return defer.succeed(None) 374 return defer.succeed(None)
375
376 def addObserver(self, *argv):
377 pass
361 378
362 379
363 class FakeClient(object): 380 class FakeClient(object):
364 """Tests involving more than one profile need one instance of this class per profile""" 381 """Tests involving more than one profile need one instance of this class per profile"""
365 382