annotate src/test/test_plugin_xep_0313.py @ 1284:41ffe2c2dddc

plugin XEP-0313: update (still draft)
author souliane <souliane@mailoo.org>
date Fri, 09 Jan 2015 10:51:12 +0100
parents 3a3e3014f9f8
children ed2c718bfe03
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
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
6 # Copyright (C) 2013, 2014 Adrien Cossa (souliane@mailoo.org)
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
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
30 from wokkel.rsm import RSMRequest
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
31 from wokkel.mam import buildForm
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
32
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
33 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
34 SERVICE = 'sat-pubsub.tazar.int'
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
35 SERVICE_JID = JID(SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
36
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
37
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
38 class XEP_0313Test(helpers.SatTestCase):
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 def setUp(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
41 self.host = helpers.FakeSAT()
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
42 self.plugin = XEP_0313(self.host)
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
43 client = self.plugin.getHandler(C.PROFILE[0])
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
44 client.makeConnection(self.host.getClient(C.PROFILE[0]).xmlstream)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
45
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
46 def test_queryArchive(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
47 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
48 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
49 <query xmlns='urn:xmpp:mam:0'/>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
50 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
51 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
52 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
53 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
54 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
55
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
56 def test_queryArchivePubsub(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
57 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
58 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
59 <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
60 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
61 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
62 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
63 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
64 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
65
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
66 def test_queryArchiveWith(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
67 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
68 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
69 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
70 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
71 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
72 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
73 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
74 <field var='with' type='jid-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
75 <value>juliet@capulet.lit</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
76 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
77 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
78 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
79 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
80 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
81 form = buildForm(with_jid=JID('juliet@capulet.lit'))
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
82 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
83 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
84 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
85
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
86 def test_queryArchiveStartEnd(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
87 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
88 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
89 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
90 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
91 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
92 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
93 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
94 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
95 <value>2010-06-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
96 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
97 <field var='end' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
98 <value>2010-07-07T13:23:54Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
99 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
100 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
101 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
102 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
103 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
104 start = datetime.datetime(2010, 6, 7, 0, 0, 0, tzinfo=tzutc())
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
105 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
106 form = buildForm(start=start, end=end)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
107 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
108 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
109 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
110
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
111 def test_queryArchiveStart(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
112 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
113 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
114 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
115 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
116 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
117 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
118 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
119 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
120 <value>2010-08-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
121 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
122 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
123 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
124 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
125 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
126 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
127 form = buildForm(start=start)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
128 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
129 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
130 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
131
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
132 def test_queryArchiveRSM(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
133 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
134 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
135 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
136 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
137 <field var='FORM_TYPE' type='hidden'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
138 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
139 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
140 <field var='start' type='text-single'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
141 <value>2010-08-07T00:00:00Z</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
142 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
143 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
144 <set xmlns='http://jabber.org/protocol/rsm'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
145 <max>10</max>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
146 </set>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
147 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
148 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
149 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
150 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
151 form = buildForm(start=start)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
152 rsm = RSMRequest(max=10)
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
153 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
154 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
155 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
156
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
157 def test_queryArchiveRSMPaging(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
158 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
159 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
160 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
161 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
162 <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
163 <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
164 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
165 <set xmlns='http://jabber.org/protocol/rsm'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
166 <max>10</max>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
167 <after>09af3-cc343-b409f</after>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
168 </set>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
169 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
170 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
171 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
172 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
173 form = buildForm(start=start)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
174 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
175 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
176 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
177 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
178
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
179 def test_queryFields(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
180 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
181 <iq type='get' id="%s" to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
182 <query xmlns='urn:xmpp:mam:0'/>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
183 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
184 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
185 d = self.plugin.queryFields(SERVICE_JID, C.PROFILE[0])
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
186 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
187 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
188
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
189 def test_queryArchiveFields(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
190 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
191 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
192 <query xmlns='urn:xmpp:mam:0'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
193 <x xmlns='jabber:x:data' type='submit'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
194 <field type='hidden' var='FORM_TYPE'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
195 <value>urn:xmpp:mam:0</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
196 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
197 <field type='text-single' var='urn:example:xmpp:free-text-search'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
198 <value>Where arth thou, my Juliet?</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
199 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
200 <field type='text-single' var='urn:example:xmpp:stanza-content'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
201 <value>{http://jabber.org/protocol/mood}mood/lonely</value>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
202 </field>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
203 </x>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
204 </query>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
205 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
206 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
207 extra = [{'fieldType': 'text-single',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
208 'var': 'urn:example:xmpp:free-text-search',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
209 'value': 'Where arth thou, my Juliet?'},
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
210 {'fieldType': 'text-single',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
211 'var': 'urn:example:xmpp:stanza-content',
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
212 'value': '{http://jabber.org/protocol/mood}mood/lonely'}]
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
213 form = buildForm(extra=extra)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
214 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
215 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
216 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
217
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
218 def test_queryPrefs(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
219 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
220 <iq type='get' id='%s' to='%s'>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
221 <prefs xmlns='urn:xmpp:mam:0'>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
222 <always/>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
223 <never/>
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
224 </prefs>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
225 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
226 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
227 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
228 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
229 return d
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
230
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
231 def test_setPrefs(self):
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
232 xml = """
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
233 <iq type='set' id='%s' to='%s'>
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
234 <prefs xmlns='urn:xmpp:mam:0' default='roster'>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
235 <always>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
236 <jid>romeo@montague.lit</jid>
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 <never>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
239 <jid>montague@montague.lit</jid>
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 </prefs>
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
242 </iq>
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
243 """ % (("H_%d" % domish.Element._idCounter), SERVICE)
1277
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
244 always = [JID('romeo@montague.lit')]
3a3e3014f9f8 plugin XEP-0313: first draft:
souliane <souliane@mailoo.org>
parents:
diff changeset
245 never = [JID('montague@montague.lit')]
1284
41ffe2c2dddc plugin XEP-0313: update (still draft)
souliane <souliane@mailoo.org>
parents: 1277
diff changeset
246 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
247 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
248 return d