Mercurial > libervia-backend
annotate sat/test/test_plugin_xep_0313.py @ 2816:114cdde9ff96
plugin XEP-0280: priority and "sent" fixes:
- carbon prioriy must be bigger than ones of encryption plugins, because the carbon copied messages must be unwrapped to be decrypted, this patch fixes it
- "sent" carbon elements was only stored and notified to frontends, it is now unwrapped and injected in normal traffic, this way other plugin can manage it, in particular encrypted elements can be decrypted
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 28 Feb 2019 18:57:06 +0100 |
parents | 003b8b4b56a7 |
children | ab2696e34d29 |
rev | line source |
---|---|
1934
2daf7b4c6756
use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents:
1910
diff
changeset
|
1 #!/usr/bin/env python2 |
1277 | 2 # -*- coding: utf-8 -*- |
3 | |
4 # SAT: a jabber client | |
2771 | 5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) |
1766 | 6 # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) |
1277 | 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 XEP-0313 """ | |
22 | |
23 from constants import Const as C | |
24 from sat.test import helpers | |
25 from sat.plugins.plugin_xep_0313 import XEP_0313 | |
26 from twisted.words.protocols.jabber.jid import JID | |
27 from twisted.words.xish import domish | |
1910 | 28 from wokkel.data_form import Field |
1277 | 29 from dateutil.tz import tzutc |
30 import datetime | |
1285
ed2c718bfe03
tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents:
1284
diff
changeset
|
31 |
ed2c718bfe03
tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents:
1284
diff
changeset
|
32 # TODO: change this when RSM and MAM are in wokkel |
2413
70399d1acb47
tmp: removed sat.tmp hierarchy and fixed references to it as it is now an independant sat_tmp repository
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
33 from sat_tmp.wokkel.rsm import RSMRequest |
70399d1acb47
tmp: removed sat.tmp hierarchy and fixed references to it as it is now an independant sat_tmp repository
Goffi <goffi@goffi.org>
parents:
1934
diff
changeset
|
34 from sat_tmp.wokkel.mam import buildForm, MAMRequest |
1277 | 35 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
36 NS_PUBSUB = "http://jabber.org/protocol/pubsub" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
37 SERVICE = "sat-pubsub.tazar.int" |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
38 SERVICE_JID = JID(SERVICE) |
1277 | 39 |
40 | |
41 class XEP_0313Test(helpers.SatTestCase): | |
42 def setUp(self): | |
43 self.host = helpers.FakeSAT() | |
44 self.plugin = XEP_0313(self.host) | |
1910 | 45 self.client = self.host.getClient(C.PROFILE[0]) |
46 mam_client = self.plugin.getHandler(C.PROFILE[0]) | |
47 mam_client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream) | |
1277 | 48 |
49 def test_queryArchive(self): | |
50 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
51 <iq type='set' id='%s' to='%s'> |
1910 | 52 <query xmlns='urn:xmpp:mam:1'/> |
1277 | 53 </iq> |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
54 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
55 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
56 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
57 ) |
1910 | 58 d = self.plugin.queryArchive(self.client, MAMRequest(), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
59 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
60 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
61 ) |
1277 | 62 return d |
63 | |
64 def test_queryArchivePubsub(self): | |
65 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
66 <iq type='set' id='%s' to='%s'> |
1910 | 67 <query xmlns='urn:xmpp:mam:1' node='fdp/submitted/capulet.lit/sonnets' /> |
1277 | 68 </iq> |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
69 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
70 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
71 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
72 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
73 d = self.plugin.queryArchive( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
74 self.client, MAMRequest(node="fdp/submitted/capulet.lit/sonnets"), SERVICE_JID |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
75 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
76 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
77 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
78 ) |
1277 | 79 return d |
80 | |
81 def test_queryArchiveWith(self): | |
82 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
83 <iq type='set' id='%s' to='%s'> |
1910 | 84 <query xmlns='urn:xmpp:mam:1'> |
1277 | 85 <x xmlns='jabber:x:data' type='submit'> |
86 <field var='FORM_TYPE' type='hidden'> | |
1910 | 87 <value>urn:xmpp:mam:1</value> |
1277 | 88 </field> |
89 <field var='with' type='jid-single'> | |
90 <value>juliet@capulet.lit</value> | |
91 </field> | |
92 </x> | |
93 </query> | |
94 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
95 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
96 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
97 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
98 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
99 form = buildForm(with_jid=JID("juliet@capulet.lit")) |
1910 | 100 d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
101 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
102 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
103 ) |
1277 | 104 return d |
105 | |
106 def test_queryArchiveStartEnd(self): | |
107 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
108 <iq type='set' id='%s' to='%s'> |
1910 | 109 <query xmlns='urn:xmpp:mam:1'> |
1277 | 110 <x xmlns='jabber:x:data' type='submit'> |
111 <field var='FORM_TYPE' type='hidden'> | |
1910 | 112 <value>urn:xmpp:mam:1</value> |
1277 | 113 </field> |
114 <field var='start' type='text-single'> | |
115 <value>2010-06-07T00:00:00Z</value> | |
116 </field> | |
117 <field var='end' type='text-single'> | |
118 <value>2010-07-07T13:23:54Z</value> | |
119 </field> | |
120 </x> | |
121 </query> | |
122 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
123 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
124 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
125 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
126 ) |
1277 | 127 start = datetime.datetime(2010, 6, 7, 0, 0, 0, tzinfo=tzutc()) |
128 end = datetime.datetime(2010, 7, 7, 13, 23, 54, tzinfo=tzutc()) | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
129 form = buildForm(start=start, end=end) |
1910 | 130 d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
131 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
132 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
133 ) |
1277 | 134 return d |
135 | |
136 def test_queryArchiveStart(self): | |
137 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
138 <iq type='set' id='%s' to='%s'> |
1910 | 139 <query xmlns='urn:xmpp:mam:1'> |
1277 | 140 <x xmlns='jabber:x:data' type='submit'> |
141 <field var='FORM_TYPE' type='hidden'> | |
1910 | 142 <value>urn:xmpp:mam:1</value> |
1277 | 143 </field> |
144 <field var='start' type='text-single'> | |
145 <value>2010-08-07T00:00:00Z</value> | |
146 </field> | |
147 </x> | |
148 </query> | |
149 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
150 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
151 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
152 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
153 ) |
1277 | 154 start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
155 form = buildForm(start=start) |
1910 | 156 d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
157 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
158 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
159 ) |
1277 | 160 return d |
161 | |
162 def test_queryArchiveRSM(self): | |
163 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
164 <iq type='set' id='%s' to='%s'> |
1910 | 165 <query xmlns='urn:xmpp:mam:1'> |
1277 | 166 <x xmlns='jabber:x:data' type='submit'> |
167 <field var='FORM_TYPE' type='hidden'> | |
1910 | 168 <value>urn:xmpp:mam:1</value> |
1277 | 169 </field> |
170 <field var='start' type='text-single'> | |
171 <value>2010-08-07T00:00:00Z</value> | |
172 </field> | |
173 </x> | |
174 <set xmlns='http://jabber.org/protocol/rsm'> | |
175 <max>10</max> | |
176 </set> | |
177 </query> | |
178 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
179 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
180 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
181 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
182 ) |
1277 | 183 start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
184 form = buildForm(start=start) |
1424 | 185 rsm = RSMRequest(max_=10) |
1910 | 186 d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
187 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
188 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
189 ) |
1277 | 190 return d |
191 | |
192 def test_queryArchiveRSMPaging(self): | |
193 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
194 <iq type='set' id='%s' to='%s'> |
1910 | 195 <query xmlns='urn:xmpp:mam:1'> |
1277 | 196 <x xmlns='jabber:x:data' type='submit'> |
1910 | 197 <field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:1</value></field> |
1277 | 198 <field var='start' type='text-single'><value>2010-08-07T00:00:00Z</value></field> |
199 </x> | |
200 <set xmlns='http://jabber.org/protocol/rsm'> | |
201 <max>10</max> | |
202 <after>09af3-cc343-b409f</after> | |
203 </set> | |
204 </query> | |
205 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
206 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
207 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
208 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
209 ) |
1277 | 210 start = datetime.datetime(2010, 8, 7, 0, 0, 0, tzinfo=tzutc()) |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
211 form = buildForm(start=start) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
212 rsm = RSMRequest(max_=10, after=u"09af3-cc343-b409f") |
1910 | 213 d = self.plugin.queryArchive(self.client, MAMRequest(form, rsm), SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
214 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
215 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
216 ) |
1277 | 217 return d |
218 | |
219 def test_queryFields(self): | |
220 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
221 <iq type='get' id="%s" to='%s'> |
1910 | 222 <query xmlns='urn:xmpp:mam:1'/> |
1277 | 223 </iq> |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
224 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
225 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
226 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
227 ) |
1910 | 228 d = self.plugin.queryFields(self.client, SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
229 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
230 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
231 ) |
1277 | 232 return d |
233 | |
234 def test_queryArchiveFields(self): | |
235 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
236 <iq type='set' id='%s' to='%s'> |
1910 | 237 <query xmlns='urn:xmpp:mam:1'> |
1277 | 238 <x xmlns='jabber:x:data' type='submit'> |
239 <field type='hidden' var='FORM_TYPE'> | |
1910 | 240 <value>urn:xmpp:mam:1</value> |
1277 | 241 </field> |
242 <field type='text-single' var='urn:example:xmpp:free-text-search'> | |
243 <value>Where arth thou, my Juliet?</value> | |
244 </field> | |
245 <field type='text-single' var='urn:example:xmpp:stanza-content'> | |
246 <value>{http://jabber.org/protocol/mood}mood/lonely</value> | |
247 </field> | |
248 </x> | |
249 </query> | |
250 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
251 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
252 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
253 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
254 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
255 extra_fields = [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
256 Field( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
257 "text-single", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
258 "urn:example:xmpp:free-text-search", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
259 "Where arth thou, my Juliet?", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
260 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
261 Field( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
262 "text-single", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
263 "urn:example:xmpp:stanza-content", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
264 "{http://jabber.org/protocol/mood}mood/lonely", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
265 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
266 ] |
1910 | 267 form = buildForm(extra_fields=extra_fields) |
268 d = self.plugin.queryArchive(self.client, MAMRequest(form), SERVICE_JID) | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
269 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
270 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
271 ) |
1277 | 272 return d |
273 | |
274 def test_queryPrefs(self): | |
275 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
276 <iq type='get' id='%s' to='%s'> |
1910 | 277 <prefs xmlns='urn:xmpp:mam:1'> |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
278 <always/> |
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
279 <never/> |
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
280 </prefs> |
1277 | 281 </iq> |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
282 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
283 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
284 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
285 ) |
1910 | 286 d = self.plugin.getPrefs(self.client, SERVICE_JID) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
287 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
288 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
289 ) |
1277 | 290 return d |
291 | |
292 def test_setPrefs(self): | |
293 xml = """ | |
1284
41ffe2c2dddc
plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents:
1277
diff
changeset
|
294 <iq type='set' id='%s' to='%s'> |
1910 | 295 <prefs xmlns='urn:xmpp:mam:1' default='roster'> |
1277 | 296 <always> |
297 <jid>romeo@montague.lit</jid> | |
298 </always> | |
299 <never> | |
300 <jid>montague@montague.lit</jid> | |
301 </never> | |
302 </prefs> | |
303 </iq> | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
304 """ % ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
305 ("H_%d" % domish.Element._idCounter), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
306 SERVICE, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
307 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
308 always = [JID("romeo@montague.lit")] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
309 never = [JID("montague@montague.lit")] |
1910 | 310 d = self.plugin.setPrefs(self.client, SERVICE_JID, always=always, never=never) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
311 d.addCallback( |
2765
378188abe941
misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)
Goffi <goffi@goffi.org>
parents:
2624
diff
changeset
|
312 lambda __: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
313 ) |
1277 | 314 return d |