annotate src/test/test_plugin_xep_0033.py @ 787:dd656d745d6a

test: added tests for XEP-0033
author souliane <souliane@mailoo.org>
date Sun, 05 Jan 2014 13:05:31 +0100
parents
children 0cb423500fbb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
1 #!/usr/bin/python
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
3
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # SAT: a jabber client
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
6 # Copyright (C) 2013 Adrien Cossa (souliane@mailoo.org)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
7
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
11 # (at your option) any later version.
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
12
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
17
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
20
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
21 """ Plugin extended addressing stanzas """
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
22
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
23 from constants import Const
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
24 from sat.test import helpers
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
25 from sat.plugins import plugin_xep_0033 as plugin
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
26 from sat.memory.memory import NO_SECURITY_LIMIT
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from sat.core.sat_main import AbortSendMessage, MessageSentAndStored
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from copy import deepcopy
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
29 from twisted.internet import defer
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
30 from wokkel.generic import parseXml
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
31 from twisted.words.protocols.jabber.jid import JID
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
32
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
33
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
34 class XEP_0033Test(helpers.SatTestCase):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
35
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
36 def setUp(self):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
37 self.host = helpers.FakeSAT()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
38 self.plugin = plugin.XEP_0033(self.host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
39
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
40 def test_messageReceived(self):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
41 self.host.memory.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
42 xml = u"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
43 <message type="chat" from="%s" to="%s" id="test_1">
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
44 <body>test</body>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
45 <addresses xmlns='http://jabber.org/protocol/address'>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
46 <address type='to' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
47 <address type='cc' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
48 <address type='bcc' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
49 </addresses>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
50 </message>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
51 """ % (Const.TEST_JID_2_STR, self.host.getClientHostJid(Const.TEST_PROFILE),
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
52 Const.TEST_JID_STR, Const.TEST_JID_2_STR, Const.TEST_JID_3_STR)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
53 stanza = parseXml(xml.encode("utf-8"))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
54 treatments = defer.Deferred()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
55 self.plugin.messageReceivedTrigger(stanza, treatments, Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
56 data = {'extra': {}}
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
57
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
58 def assert_(data):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
59 expected = ('to', Const.TEST_JID_STR, 'cc', Const.TEST_JID_2_STR, 'bcc', Const.TEST_JID_3_STR)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
60 assert(data['extra']['addresses'] == '%s:%s\n%s:%s\n%s:%s\n' % expected)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
61
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
62 treatments.addCallback(assert_)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
63 treatments.callback(data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
64
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
65 def test_sendMessageTrigger(self):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
66 mess_data = {"to": self.host.getClientHostJid(Const.TEST_PROFILE),
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
67 "type": "chat",
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
68 "message": "content",
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
69 "extra": {}
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
70 }
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
71 addresses = ('to', Const.TEST_JID_STR, 'cc', Const.TEST_JID_2_STR, 'bcc', Const.TEST_JID_3_STR)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
72 mess_data["extra"]["address"] = '%s:%s\n%s:%s\n%s:%s\n' % addresses
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
73 original_stanza = u"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
74 <message type="chat" from="%s" to="%s" id="test_1">
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
75 <body>content</body>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
76 </message>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
77 """ % (Const.TEST_JID_2_STR, self.host.getClientHostJid(Const.TEST_PROFILE))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
78 mess_data['xml'] = parseXml(original_stanza.encode("utf-8"))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
79 expected = deepcopy(mess_data['xml'])
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
80 addresses_extra = """
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
81 <addresses xmlns='http://jabber.org/protocol/address'>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
82 <address type='%s' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
83 <address type='%s' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
84 <address type='%s' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
85 </addresses>""" % addresses
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
86 addresses_element = parseXml(addresses_extra.encode('utf-8'))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
87 expected.addChild(addresses_element)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
88
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
89 def assert_(mess_data):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
90 """The mess_data that we got here as been modified by self.plugin.sendMessageTrigger,
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
91 check that the addresses element has been added to the stanza."""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
92 self.assertEqualXML(mess_data['xml'].toXml().encode("utf-8"), expected.toXml().encode("utf-8"))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
93
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
94 def fail_(failure, exception_class):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
95 """If the failure does encapsulate the expected exception, it will be silently
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
96 trapped, otherwise it will be re-raised and will make the test fail"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
97 if exception_class == MessageSentAndStored:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
98 assert_(failure.value.mess_data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
99 failure.trap(exception_class)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
100
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
101 def checkSentAndStored():
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
102 """Check that all the recipients got their messages and that the history has been filled.
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
103 /!\ see the comments in XEP_0033.sendAndStoreMessage"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
104 sent = []
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
105 stored = []
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
106 cache = set()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
107 for to_s in [addresses[1], addresses[3], addresses[5]]:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
108 to_jid = JID(to_s)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
109 host = JID(to_jid.host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
110 if self.host.memory.hasServerFeature(plugin.NS_ADDRESS, host, Const.TEST_PROFILE):
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
111 if host not in cache:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
112 sent.append(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
113 stored.append(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
114 cache.add(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
115 stored.append(to_jid)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
116 else:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
117 sent.append(to_jid)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
118 stored.append(to_jid)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
119 try:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
120 assert(len(self.host.sent_messages) == len(sent))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
121 assert(len(self.host.stored_messages) == len(stored))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
122 assert(set(self.host.sent_messages) == set(sent))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
123 assert(set(self.host.stored_messages) == set(stored))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
124 except AssertionError as e:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
125 print "----------------------------------------------------"
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
126 print "Comparing sent and stored messages failed!"
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
127 print self.host.sent_messages
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
128 print sent
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
129 print self.host.stored_messages
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
130 print stored
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
131 print "/!\ see the comments in XEP_0033.sendAndStoreMessage"
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
132 print "----------------------------------------------------"
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
133 raise e
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
134
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
135 # feature is not supported, abort the message
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
136 self.host.memory.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
137 treatments = defer.Deferred()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
138 data = deepcopy(mess_data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
139 self.plugin.sendMessageTrigger(data, treatments, Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
140 treatments.addCallbacks(assert_, lambda failure: fail_(failure, AbortSendMessage))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
141 treatments.callback(data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
142
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
143 # feature is supported
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
144 self.host.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
145 self.host.memory.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
146 self.host.memory.addServerFeature(plugin.NS_ADDRESS, self.host.getClientHostJid(Const.TEST_PROFILE), Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
147 treatments = defer.Deferred()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
148 data = deepcopy(mess_data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
149 self.plugin.sendMessageTrigger(data, treatments, Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
150 treatments.addCallbacks(assert_, lambda failure: fail_(failure, MessageSentAndStored))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
151 treatments.callback(data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
152 checkSentAndStored()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
153
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
154 # check that a wrong recipient entity is fixed by the backend
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
155 self.host.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
156 self.host.memory.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
157 self.host.memory.addServerFeature(plugin.NS_ADDRESS, self.host.getClientHostJid(Const.TEST_PROFILE), Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
158 treatments = defer.Deferred()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
159 data = deepcopy(mess_data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
160 data["to"] = Const.TEST_JID
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
161 self.plugin.sendMessageTrigger(data, treatments, Const.TEST_PROFILE)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
162 treatments.addCallbacks(assert_, lambda failure: fail_(failure, MessageSentAndStored))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
163 treatments.callback(mess_data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
164 checkSentAndStored()