annotate src/test/test_plugin_xep_0033.py @ 937:255e6953b2c3

primitivus: do not display the presence/status dialog if the profile is not connected
author souliane <souliane@mailoo.org>
date Tue, 25 Mar 2014 17:26:31 +0100
parents 861593a5652b
children e1842ebcb2f3
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
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 793
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 793
diff changeset
6 # Copyright (C) 2013, 2014 Adrien Cossa (souliane@mailoo.org)
787
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.core.sat_main import AbortSendMessage, MessageSentAndStored
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from copy import deepcopy
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from twisted.internet import defer
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
29 from wokkel.generic import parseXml
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
30 from twisted.words.protocols.jabber.jid import JID
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
31 import logging
787
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>
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
51 """ % (Const.JID_STR[1], self.host.getClientHostJid(Const.PROFILE[0]),
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
52 Const.JID_STR[0], Const.JID_STR[1], Const.JID_STR[2])
787
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()
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
55 self.plugin.messageReceivedTrigger(stanza, treatments, Const.PROFILE[0])
787
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
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
58 def cb(data):
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
59 expected = ('to', Const.JID_STR[0], 'cc', Const.JID_STR[1], 'bcc', Const.JID_STR[2])
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
60 msg = 'Expected: %s\nGot: %s' % (expected, data['extra']['addresses'])
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
61 self.assertEqual(data['extra']['addresses'], '%s:%s\n%s:%s\n%s:%s\n' % expected, msg)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
62
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
63 treatments.addCallback(cb)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
64 treatments.callback(data)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
65
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
66 def test_sendMessageTrigger(self):
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
67 mess_data = {"to": self.host.getClientHostJid(Const.PROFILE[0]),
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
68 "type": "chat",
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
69 "message": "content",
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
70 "extra": {}
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
71 }
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
72 addresses = ('to', Const.JID_STR[0], 'cc', Const.JID_STR[1], 'bcc', Const.JID_STR[2])
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
73 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
74 original_stanza = u"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
75 <message type="chat" from="%s" to="%s" id="test_1">
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
76 <body>content</body>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
77 </message>
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
78 """ % (Const.JID_STR[1], self.host.getClientHostJid(Const.PROFILE[0]))
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
79 mess_data['xml'] = parseXml(original_stanza.encode("utf-8"))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
80 expected = deepcopy(mess_data['xml'])
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
81 addresses_extra = """
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
82 <addresses xmlns='http://jabber.org/protocol/address'>
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 <address type='%s' jid='%s'/>
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
86 </addresses>""" % addresses
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
87 addresses_element = parseXml(addresses_extra.encode('utf-8'))
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
88 expected.addChild(addresses_element)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
89
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
90 def assertAddresses(mess_data):
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
91 """The mess_data that we got here has been modified by self.plugin.sendMessageTrigger,
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
92 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
93 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
94
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
95 def sendMessageErrback(failure, exception_class):
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
96 """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
97 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
98 if exception_class == MessageSentAndStored:
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
99 assertAddresses(failure.value.mess_data)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
100 failure.trap(exception_class)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
101
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
102 def checkSentAndStored():
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
103 """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
104 /!\ see the comments in XEP_0033.sendAndStoreMessage"""
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
105 sent = []
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
106 stored = []
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
107 cache = set()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
108 for to_s in [addresses[1], addresses[3], addresses[5]]:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
109 to_jid = JID(to_s)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
110 host = JID(to_jid.host)
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
111 logger = logging.getLogger()
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
112 level = logger.getEffectiveLevel()
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
113 logger.setLevel(logging.ERROR) # remove warning pollution
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
114 if self.host.memory.hasServerFeature(plugin.NS_ADDRESS, host, Const.PROFILE[0]):
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
115 if host not in cache:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
116 sent.append(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
117 stored.append(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
118 cache.add(host)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
119 stored.append(to_jid)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
120 else:
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
121 sent.append(to_jid)
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
122 stored.append(to_jid)
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
123 logger.setLevel(level)
789
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
124 msg = "/!\ see the comments in XEP_0033.sendAndStoreMessage"
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
125 self.assertEqualUnsortedList(self.host.sent_messages, sent, msg)
0cb423500fbb test: use the SatTestCase methods instead of builtin "assert" in tests for memory, plugin xep-0033
souliane <souliane@mailoo.org>
parents: 787
diff changeset
126 self.assertEqualUnsortedList(self.host.stored_messages, stored, msg)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
127
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
128 def trigger(data, exception):
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
129 """Execute self.plugin.sendMessageTrigger with a different logging
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
130 level to not pollute the output, then check that the plugin did its
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
131 job. It should abort sending the message or add the extended
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
132 addressing information to the stanza.
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
133 @param data: the data to be processed by self.plugin.sendMessageTrigger
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
134 @param exception: AbortSendMessage or MessageSentAndStored
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
135 """
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
136 logger = logging.getLogger()
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
137 level = logger.getEffectiveLevel()
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
138 logger.setLevel(logging.ERROR) # remove warning pollution
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
139 pre_treatments = defer.Deferred()
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
140 post_treatments = defer.Deferred()
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
141 self.plugin.sendMessageTrigger(data, pre_treatments, post_treatments, Const.PROFILE[0])
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
142 post_treatments.callback(data)
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
143 logger.setLevel(level)
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
144 post_treatments.addCallbacks(assertAddresses, lambda failure: sendMessageErrback(failure, exception))
793
cb2db0d85029 test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents: 792
diff changeset
145
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
146 # feature is not supported, abort the message
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
147 self.host.memory.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
148 data = deepcopy(mess_data)
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
149 trigger(data, AbortSendMessage)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
150
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
151 # feature is supported
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
152 self.host.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
153 self.host.memory.init()
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
154 self.host.memory.addServerFeature(plugin.NS_ADDRESS, self.host.getClientHostJid(Const.PROFILE[0]), Const.PROFILE[0])
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
155 data = deepcopy(mess_data)
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
156 trigger(data, MessageSentAndStored)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
157 checkSentAndStored()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
158
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
159 # 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
160 self.host.init()
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
161 self.host.memory.init()
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
162 self.host.memory.addServerFeature(plugin.NS_ADDRESS, self.host.getClientHostJid(Const.PROFILE[0]), Const.PROFILE[0])
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
163 data = deepcopy(mess_data)
792
2136be5a44a8 test: define the constants JIDs and profiles as lists
souliane <souliane@mailoo.org>
parents: 789
diff changeset
164 data["to"] = Const.JID[0]
924
861593a5652b test: fix tests fo plugins XEP-0033 and XEP-0085
souliane <souliane@mailoo.org>
parents: 915
diff changeset
165 trigger(data, MessageSentAndStored)
787
dd656d745d6a test: added tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
diff changeset
166 checkSentAndStored()