Mercurial > libervia-backend
annotate sat/test/test_plugin_xep_0033.py @ 2582:2e6864b1d577
quick frontend (contact list): don't store "nick" for group contacts:
plugin XEP-0054 may associate a "nick" with a bare jid, which in case of MUC can cause trouble (Primitivus for instance will use the nick instead of the name of the room).
This hack avoid this issue for now.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 11 May 2018 17:13:58 +0200 |
parents | 26edcf3a30eb |
children | 56f94936df1e |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1909
diff
changeset
|
1 #!/usr/bin/env python2 |
787 | 2 # -*- coding: utf-8 -*- |
3 | |
4 # SAT: a jabber client | |
2483 | 5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org) |
1766 | 6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) |
787 | 7 |
8 # This program is free software: you can redistribute it and/or modify | |
9 # it under the terms of the GNU Affero General Public License as published by | |
10 # the Free Software Foundation, either version 3 of the License, or | |
11 # (at your option) any later version. | |
12 | |
13 # This program is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 # GNU Affero General Public License for more details. | |
17 | |
18 # You should have received a copy of the GNU Affero General Public License | |
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | |
21 """ Plugin extended addressing stanzas """ | |
22 | |
23 from constants import Const | |
24 from sat.test import helpers | |
25 from sat.plugins import plugin_xep_0033 as plugin | |
1057
7ea0215e7092
test: fixes the tests for plugin XEP-0033
souliane <souliane@mailoo.org>
parents:
999
diff
changeset
|
26 from sat.core.exceptions import CancelError |
787 | 27 from twisted.internet import defer |
28 from wokkel.generic import parseXml | |
29 from twisted.words.protocols.jabber.jid import JID | |
30 | |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
31 PROFILE_INDEX = 0 |
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
32 PROFILE = Const.PROFILE[PROFILE_INDEX] |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
33 JID_STR_FROM = Const.JID_STR[1] |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
34 JID_STR_TO = Const.PROFILE_DICT[PROFILE].host |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
35 JID_STR_X_TO = Const.JID_STR[0] |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
36 JID_STR_X_CC = Const.JID_STR[1] |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
37 JID_STR_X_BCC = Const.JID_STR[2] |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
38 |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
39 ADDRS = ('to', JID_STR_X_TO, 'cc', JID_STR_X_CC, 'bcc', JID_STR_X_BCC) |
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
40 |
787 | 41 |
42 class XEP_0033Test(helpers.SatTestCase): | |
43 | |
44 def setUp(self): | |
45 self.host = helpers.FakeSAT() | |
46 self.plugin = plugin.XEP_0033(self.host) | |
47 | |
48 def test_messageReceived(self): | |
1271 | 49 self.host.memory.reinit() |
787 | 50 xml = u""" |
51 <message type="chat" from="%s" to="%s" id="test_1"> | |
52 <body>test</body> | |
53 <addresses xmlns='http://jabber.org/protocol/address'> | |
54 <address type='to' jid='%s'/> | |
55 <address type='cc' jid='%s'/> | |
56 <address type='bcc' jid='%s'/> | |
57 </addresses> | |
58 </message> | |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
59 """ % (JID_STR_FROM, JID_STR_TO, JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC) |
787 | 60 stanza = parseXml(xml.encode("utf-8")) |
61 treatments = defer.Deferred() | |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
62 self.plugin.messageReceivedTrigger(self.host.getClient(PROFILE), stanza, treatments) |
787 | 63 data = {'extra': {}} |
64 | |
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
|
65 def cb(data): |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
66 expected = ('to', JID_STR_X_TO, 'cc', JID_STR_X_CC, 'bcc', JID_STR_X_BCC) |
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
|
67 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
|
68 self.assertEqual(data['extra']['addresses'], '%s:%s\n%s:%s\n%s:%s\n' % expected, msg) |
787 | 69 |
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
|
70 treatments.addCallback(cb) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
71 return treatments.callback(data) |
787 | 72 |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
73 def _get_mess_data(self): |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
74 mess_data = {"to": JID(JID_STR_TO), |
787 | 75 "type": "chat", |
76 "message": "content", | |
77 "extra": {} | |
78 } | |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
79 mess_data["extra"]["address"] = '%s:%s\n%s:%s\n%s:%s\n' % ADDRS |
787 | 80 original_stanza = u""" |
81 <message type="chat" from="%s" to="%s" id="test_1"> | |
82 <body>content</body> | |
83 </message> | |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
84 """ % (JID_STR_FROM, JID_STR_TO) |
787 | 85 mess_data['xml'] = parseXml(original_stanza.encode("utf-8")) |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
86 return mess_data |
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
87 |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
88 def _assertAddresses(self, mess_data): |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
89 """The mess_data that we got here has been modified by self.plugin.messageSendTrigger, |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
90 check that the addresses element has been added to the stanza.""" |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
91 expected = self._get_mess_data()['xml'] |
787 | 92 addresses_extra = """ |
93 <addresses xmlns='http://jabber.org/protocol/address'> | |
94 <address type='%s' jid='%s'/> | |
95 <address type='%s' jid='%s'/> | |
96 <address type='%s' jid='%s'/> | |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
97 </addresses>""" % ADDRS |
787 | 98 addresses_element = parseXml(addresses_extra.encode('utf-8')) |
99 expected.addChild(addresses_element) | |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
100 self.assertEqualXML(mess_data['xml'].toXml().encode("utf-8"), expected.toXml().encode("utf-8")) |
787 | 101 |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
102 def _checkSentAndStored(self): |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
103 """Check that all the recipients got their messages and that the history has been filled. |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
104 /!\ see the comments in XEP_0033.sendAndStoreMessage""" |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
105 sent = [] |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
106 stored = [] |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
107 d_list = [] |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
108 |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
109 def cb(entities, to_jid): |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
110 if host in entities: |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
111 if host not in sent: # send the message to the entity offering the feature |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
112 sent.append(host) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
113 stored.append(host) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
114 stored.append(to_jid) # store in history for each recipient |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
115 else: # feature not supported, use normal behavior |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
116 sent.append(to_jid) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
117 stored.append(to_jid) |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
118 helpers.unmuteLogging() |
1272
7fbc858cd1cd
test: fixes tests for XEP-0033
souliane <souliane@mailoo.org>
parents:
1271
diff
changeset
|
119 |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
120 for to_s in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
121 to_jid = JID(to_s) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
122 host = JID(to_jid.host) |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
123 helpers.muteLogging() |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
124 d = self.host.findFeaturesSet([plugin.NS_ADDRESS], jid_=host, profile=PROFILE) |
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
125 d.addCallback(cb, to_jid) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
126 d_list.append(d) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
127 |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
128 def cb_list(dummy): |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
129 msg = "/!\ see the comments in XEP_0033.sendAndStoreMessage" |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
130 sent_recipients = [JID(elt['to']) for elt in self.host.getSentMessages(PROFILE_INDEX)] |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
131 self.assertEqualUnsortedList(sent_recipients, sent, msg) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
132 self.assertEqualUnsortedList(self.host.stored_messages, stored, msg) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
133 |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
134 return defer.DeferredList(d_list).addCallback(cb_list) |
793
cb2db0d85029
test: silent info/warning that were polluting the output
souliane <souliane@mailoo.org>
parents:
792
diff
changeset
|
135 |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
136 def _trigger(self, data): |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
137 """Execute self.plugin.messageSendTrigger with a different logging |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
138 level to not pollute the output, then check that the plugin did its |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
139 job. It should abort sending the message or add the extended |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
140 addressing information to the stanza. |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
141 @param data: the data to be processed by self.plugin.messageSendTrigger |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
142 """ |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
143 pre_treatments = defer.Deferred() |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
144 post_treatments = defer.Deferred() |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
145 helpers.muteLogging() |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
146 self.plugin.messageSendTrigger(self.host.getClient[PROFILE], data, pre_treatments, post_treatments) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
147 post_treatments.callback(data) |
1909
0681d69cbe0a
test: add helpers methods muteLogging and unmuteLogging
souliane <souliane@mailoo.org>
parents:
1766
diff
changeset
|
148 helpers.unmuteLogging() |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
149 post_treatments.addCallbacks(self._assertAddresses, lambda failure: failure.trap(CancelError)) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
150 return post_treatments |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
151 |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
152 def test_messageSendTriggerFeatureNotSupported(self): |
787 | 153 # feature is not supported, abort the message |
1271 | 154 self.host.memory.reinit() |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
155 data = self._get_mess_data() |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
156 return self._trigger(data) |
787 | 157 |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
158 def test_messageSendTriggerFeatureSupported(self): |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
159 # feature is supported by the main target server |
1271 | 160 self.host.reinit() |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
161 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
162 data = self._get_mess_data() |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
163 d = self._trigger(data) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
164 return d.addCallback(lambda dummy: self._checkSentAndStored()) |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
165 |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
166 def test_messageSendTriggerFeatureFullySupported(self): |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
167 # feature is supported by all target servers |
1271 | 168 self.host.reinit() |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
169 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
170 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
171 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
172 data = self._get_mess_data() |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
173 d = self._trigger(data) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
174 return d.addCallback(lambda dummy: self._checkSentAndStored()) |
787 | 175 |
1955
633b5c21aefd
backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
176 def test_messageSendTriggerFixWrongEntity(self): |
787 | 177 # check that a wrong recipient entity is fixed by the backend |
1271 | 178 self.host.reinit() |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
179 self.host.addFeature(JID(JID_STR_TO), plugin.NS_ADDRESS, PROFILE) |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
180 for dest in (JID_STR_X_TO, JID_STR_X_CC, JID_STR_X_BCC): |
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
181 self.host.addFeature(JID(JID(dest).host), plugin.NS_ADDRESS, PROFILE) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
182 data = self._get_mess_data() |
999
c37a24922f27
plugin XEP_0033: fixes the server part and the tests
souliane <souliane@mailoo.org>
parents:
997
diff
changeset
|
183 data["to"] = JID(JID_STR_X_TO) |
1278
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
184 d = self._trigger(data) |
347aee3a3f5c
test: fix/improve tests for plugins XEP-0033 and XEP-0085 (mainly to return a Deferred)
souliane <souliane@mailoo.org>
parents:
1272
diff
changeset
|
185 return d.addCallback(lambda dummy: self._checkSentAndStored()) |