annotate src/test/test_plugin_xep_0313.py @ 1623:ec48b35309dc

jp: use the new actionsGet method
author Goffi <goffi@goffi.org>
date Tue, 17 Nov 2015 21:29:03 +0100
parents 2d8fccec84e8
children d17772b0fe22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
1 #!/usr/bin/python
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
3
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
4 # SAT: a jabber client
1396
069ad98b360d 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 1285
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Jérôme Poisson (goffi@goffi.org)
069ad98b360d 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 1285
diff changeset
6 # Copyright (C) 2013, 2014, 2015 Adrien Cossa (souliane@mailoo.org)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
7
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
8 # This program is free software: you can redistribute it and/or modify
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
11 # (at your option) any later version.
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
12
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
16 # GNU Affero General Public License for more details.
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
17
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
20
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
21 """ Plugin XEP-0313 """
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
22
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
23 from constants import Const as C
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
24 from sat.test import helpers
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
25 from sat.plugins.plugin_xep_0313 import XEP_0313
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
26 from twisted.words.protocols.jabber.jid import JID
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
27 from twisted.words.xish import domish
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
28 from dateutil.tz import tzutc
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
29 import datetime
1285
ed2c718bfe03 tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents: 1284
diff changeset
30
ed2c718bfe03 tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents: 1284
diff changeset
31 # TODO: change this when RSM and MAM are in wokkel
ed2c718bfe03 tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents: 1284
diff changeset
32 from sat.tmp.wokkel.rsm import RSMRequest
ed2c718bfe03 tmp, plugins: fixes the imports fron sat.tmp
souliane <souliane@mailoo.org>
parents: 1284
diff changeset
33 from sat.tmp.wokkel.mam import buildForm
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
34
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
35 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
36 SERVICE = 'sat-pubsub.tazar.int'
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
37 SERVICE_JID = JID(SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
38
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
39
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
40 class XEP_0313Test(helpers.SatTestCase):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
41
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
42 def setUp(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
43 self.host = helpers.FakeSAT()
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
44 self.plugin = XEP_0313(self.host)
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
45 client = self.plugin.getHandler(C.PROFILE[0])
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
46 client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
47
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
48 def test_queryArchive(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
49 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
50 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
51 <query xmlns='urn:xmpp:mam:0'/>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
52 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
53 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
54 d = self.plugin.queryArchive(SERVICE_JID, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
55 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
56 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
57
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
58 def test_queryArchivePubsub(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
59 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
60 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
61 <query xmlns='urn:xmpp:mam:0' node='fdp/submitted/capulet.lit/sonnets' />
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
62 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
63 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
64 d = self.plugin.queryArchive(SERVICE_JID, node="fdp/submitted/capulet.lit/sonnets", profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
65 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
66 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
67
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
68 def test_queryArchiveWith(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
69 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
70 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
71 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
72 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
73 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
74 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
75 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
76 <field var='with' type='jid-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
77 <value>juliet@capulet.lit</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
78 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
79 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
80 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
81 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
82 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
83 form = buildForm(with_jid=JID('juliet@capulet.lit'))
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
84 d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
85 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
86 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
87
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
88 def test_queryArchiveStartEnd(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
89 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
90 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
91 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
92 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
93 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
94 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
95 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
96 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
97 <value>2010-06-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
98 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
99 <field var='end' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
100 <value>2010-07-07T13:23:54Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
101 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
102 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
103 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
104 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
105 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
106 start = datetime.datetime(2010, 6, 7, 0, 0, 0, tzinfo=tzutc())
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
107 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
108 form = buildForm(start=start, end=end)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
109 d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
110 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
111 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
112
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
113 def test_queryArchiveStart(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
114 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
115 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
116 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
117 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
118 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
119 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
120 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
121 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
122 <value>2010-08-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
123 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
124 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
125 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
126 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
127 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
128 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
129 form = buildForm(start=start)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
130 d = self.plugin.queryArchive(SERVICE_JID, form, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
131 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
132 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
133
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
134 def test_queryArchiveRSM(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
135 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
136 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
137 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
138 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
139 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
140 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
141 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
142 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
143 <value>2010-08-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
144 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
145 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
146 <set xmlns='http://jabber.org/protocol/rsm'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
147 <max>10</max>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
148 </set>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
149 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
150 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
151 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
152 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
153 form = buildForm(start=start)
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
154 rsm = RSMRequest(max_=10)
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
155 d = self.plugin.queryArchive(SERVICE_JID, form=form, rsm=rsm, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
156 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
157 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
158
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
159 def test_queryArchiveRSMPaging(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
160 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
161 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
162 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
163 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
164 <field var='FORM_TYPE' type='hidden'><value>urn:xmpp:mam:0</value></field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
165 <field var='start' type='text-single'><value>2010-08-07T00:00:00Z</value></field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
166 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
167 <set xmlns='http://jabber.org/protocol/rsm'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
168 <max>10</max>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
169 <after>09af3-cc343-b409f</after>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
170 </set>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
171 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
172 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
173 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
174 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
175 form = buildForm(start=start)
1424
2d8fccec84e8 core (tests): test fixes
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
176 rsm = RSMRequest(max_=10, after=u'09af3-cc343-b409f')
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
177 d = self.plugin.queryArchive(SERVICE_JID, form=form, rsm=rsm, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
178 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
179 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
180
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
181 def test_queryFields(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
182 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
183 <iq type='get' id="%s" to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
184 <query xmlns='urn:xmpp:mam:0'/>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
185 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
186 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
187 d = self.plugin.queryFields(SERVICE_JID, C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
188 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
189 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
190
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
191 def test_queryArchiveFields(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
192 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
193 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
194 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
195 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
196 <field type='hidden' var='FORM_TYPE'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
197 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
198 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
199 <field type='text-single' var='urn:example:xmpp:free-text-search'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
200 <value>Where arth thou, my Juliet?</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
201 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
202 <field type='text-single' var='urn:example:xmpp:stanza-content'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
203 <value>{http://jabber.org/protocol/mood}mood/lonely</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
204 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
205 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
206 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
207 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
208 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
209 extra = [{'fieldType': 'text-single',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
210 'var': 'urn:example:xmpp:free-text-search',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
211 'value': 'Where arth thou, my Juliet?'},
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
212 {'fieldType': 'text-single',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
213 'var': 'urn:example:xmpp:stanza-content',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
214 'value': '{http://jabber.org/protocol/mood}mood/lonely'}]
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
215 form = buildForm(extra=extra)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
216 d = self.plugin.queryArchive(SERVICE_JID, form=form, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
217 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
218 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
219
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
220 def test_queryPrefs(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
221 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
222 <iq type='get' id='%s' to='%s'>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
223 <prefs xmlns='urn:xmpp:mam:0'>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
224 <always/>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
225 <never/>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
226 </prefs>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
227 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
228 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
229 d = self.plugin.getPrefs(SERVICE_JID, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
230 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
231 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
232
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
233 def test_setPrefs(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
234 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
235 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
236 <prefs xmlns='urn:xmpp:mam:0' default='roster'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
237 <always>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
238 <jid>romeo@montague.lit</jid>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
239 </always>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
240 <never>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
241 <jid>montague@montague.lit</jid>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
242 </never>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
243 </prefs>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
244 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
245 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
246 always = [JID('romeo@montague.lit')]
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
247 never = [JID('montague@montague.lit')]
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
248 d = self.plugin.setPrefs(SERVICE_JID, always=always, never=never, profile_key=C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
249 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), xml, True))
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
250 return d