annotate sat_pubsub/test/test_gateway.py @ 260:f0cd02c032b3

publish model management
author Goffi <goffi@goffi.org>
date Mon, 06 May 2013 00:26:37 +0200
parents d55620ceafed
children 6ba0d6def7f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
1 #!/usr/bin/python
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
2 #-*- coding: utf-8 -*-
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
3
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
4 """
235
64f780413b82 fixed Ralph Meijer copyright years (last commit was in 2011, not in 2009)
Goffi <goffi@goffi.org>
parents: 234
diff changeset
5 Copyright (c) 2003-2011 Ralph Meijer
255
d55620ceafed copyright update
Goffi <goffi@goffi.org>
parents: 235
diff changeset
6 Copyright (c) 2012, 2013 Jérôme Poisson
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
7
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
8
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
9 This program is free software: you can redistribute it and/or modify
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
10 it under the terms of the GNU Affero General Public License as published by
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
11 the Free Software Foundation, either version 3 of the License, or
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
12 (at your option) any later version.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
13
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
14 This program is distributed in the hope that it will be useful,
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
17 GNU Affero General Public License for more details.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
18
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
19 You should have received a copy of the GNU Affero General Public License
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
21 --
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
22
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
23 This program is based on Idavoll (http://idavoll.ik.nu/),
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
24 originaly written by Ralph Meijer (http://ralphm.net/blog/)
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
25 It is sublicensed under AGPL v3 (or any later version) as allowed by the original
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
26 license.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
27
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
28 --
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
29
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
30 Here is a copy of the original license:
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
31
235
64f780413b82 fixed Ralph Meijer copyright years (last commit was in 2011, not in 2009)
Goffi <goffi@goffi.org>
parents: 234
diff changeset
32 Copyright (c) 2003-2011 Ralph Meijer
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
33
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
34 Permission is hereby granted, free of charge, to any person obtaining
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
35 a copy of this software and associated documentation files (the
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
36 "Software"), to deal in the Software without restriction, including
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
37 without limitation the rights to use, copy, modify, merge, publish,
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
38 distribute, sublicense, and/or sell copies of the Software, and to
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
39 permit persons to whom the Software is furnished to do so, subject to
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
40 the following conditions:
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
41
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
42 The above copyright notice and this permission notice shall be
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
43 included in all copies or substantial portions of the Software.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
44
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
45 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
46 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
47 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
48 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
49 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
50 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
51 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
52
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
53 """
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
54
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
55 """
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
56 Tests for L{idavoll.gateway}.
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
57
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58 Note that some tests are functional tests that require a running idavoll
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59 service.
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
60 """
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
61
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
62 from twisted.internet import defer
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
63 from twisted.trial import unittest
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
64 from twisted.web import error
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
65 from twisted.words.xish import domish
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
66
234
51af2ed8bd50 replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents: 233
diff changeset
67 from sat_pubsub import gateway
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
68
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
69 AGENT = "Idavoll Test Script"
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
70 NS_ATOM = "http://www.w3.org/2005/Atom"
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
71
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
72 TEST_ENTRY = domish.Element((NS_ATOM, 'entry'))
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
73 TEST_ENTRY.addElement("id",
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
74 content="urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
75 TEST_ENTRY.addElement("title", content="Atom-Powered Robots Run Amok")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
76 TEST_ENTRY.addElement("author").addElement("name", content="John Doe")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
77 TEST_ENTRY.addElement("content", content="Some text.")
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
78
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
79 baseURI = "http://localhost:8086/"
198
e404775b12df Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents: 191
diff changeset
80 componentJID = "pubsub"
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
81
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
82 class GatewayTest(unittest.TestCase):
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
83 timeout = 2
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
84
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
85 def setUp(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
86 self.client = gateway.GatewayClient(baseURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
87 self.client.startService()
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
88 self.addCleanup(self.client.stopService)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
89
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
90 def trapConnectionRefused(failure):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
91 from twisted.internet.error import ConnectionRefusedError
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
92 failure.trap(ConnectionRefusedError)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
93 raise unittest.SkipTest("Gateway to test against is not available")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
94
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
95 def trapNotFound(failure):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
96 from twisted.web.error import Error
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
97 failure.trap(Error)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
98
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
99 d = self.client.ping()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
100 d.addErrback(trapConnectionRefused)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
101 d.addErrback(trapNotFound)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
102 return d
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
103
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
104
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
105 def tearDown(self):
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
106 return self.client.stopService()
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
107
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
108
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
109 def test_create(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
110
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
111 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
112 self.assertIn('uri', response)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
113
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
114 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
115 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
116 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
117
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
118 def test_publish(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
119
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
120 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
121 self.assertIn('uri', response)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
122
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
123 d = self.client.publish(TEST_ENTRY)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
124 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
125 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
126
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
127 def test_publishExistingNode(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
128
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
129 def cb2(response, xmppURI):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
130 self.assertEquals(xmppURI, response['uri'])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
131
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
132 def cb1(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
133 xmppURI = response['uri']
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
134 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
135 d.addCallback(cb2, xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
136 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
137
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
138 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
139 d.addCallback(cb1)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
140 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
141
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
142 def test_publishNonExisting(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
143 def cb(err):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
144 self.assertEqual('404', err.status)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
145
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
146 d = self.client.publish(TEST_ENTRY, 'xmpp:%s?node=test' % componentJID)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
147 self.assertFailure(d, error.Error)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
148 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
149 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
150
209
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
151 def test_delete(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
152 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
153 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
154 d = self.client.delete(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
155 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
156
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
157 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
158 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
159 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
160
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
161 def test_deleteWithRedirect(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
162 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
163 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
164 redirectURI = 'xmpp:%s?node=test' % componentJID
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
165 d = self.client.delete(xmppURI, redirectURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
166 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
167
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
168 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
169 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
170 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
171
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
172 def test_deleteNotification(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
173 def onNotification(data, headers):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
174 try:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
175 self.assertTrue(headers.hasHeader('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
176 self.assertEquals(['DELETED'], headers.getRawHeaders('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
177 self.assertFalse(headers.hasHeader('Link'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
178 except:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
179 self.client.deferred.errback()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
180 else:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
181 self.client.deferred.callback(None)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
182
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
183 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
184 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
185 d = self.client.subscribe(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
186 d.addCallback(lambda _: xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
187 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
188
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
189 def cb2(xmppURI):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
190 d = self.client.delete(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
191 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
192
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
193 self.client.callback = onNotification
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
194 self.client.deferred = defer.Deferred()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
195 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
196 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
197 d.addCallback(cb2)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
198 return defer.gatherResults([d, self.client.deferred])
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
199
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
200 def test_deleteNotificationWithRedirect(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
201 redirectURI = 'xmpp:%s?node=test' % componentJID
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
202
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
203 def onNotification(data, headers):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
204 try:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
205 self.assertTrue(headers.hasHeader('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
206 self.assertEquals(['DELETED'], headers.getRawHeaders('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
207 self.assertEquals(['<%s>; rel=alternate' % redirectURI],
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
208 headers.getRawHeaders('Link'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
209 except:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
210 self.client.deferred.errback()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
211 else:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
212 self.client.deferred.callback(None)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
213
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
214 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
215 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
216 d = self.client.subscribe(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
217 d.addCallback(lambda _: xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
218 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
219
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
220 def cb2(xmppURI):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
221 d = self.client.delete(xmppURI, redirectURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
222 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
223
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
224 self.client.callback = onNotification
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
225 self.client.deferred = defer.Deferred()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
226 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
227 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
228 d.addCallback(cb2)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
229 return defer.gatherResults([d, self.client.deferred])
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
230
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
231 def test_list(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
232 d = self.client.listNodes()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
233 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
234
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
235 def test_subscribe(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
236 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
237 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
238 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
239 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
240
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
241 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
242 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
243 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
244
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
245 def test_subscribeGetNotification(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
246
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
247 def onNotification(data, headers):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
248 self.client.deferred.callback(None)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
249
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
250 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
251 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
252 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
253 d.addCallback(lambda _: xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
254 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
255
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
256 def cb2(xmppURI):
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
257 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
258 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
259
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
260
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
261 self.client.callback = onNotification
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
262 self.client.deferred = defer.Deferred()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
263 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
264 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
265 d.addCallback(cb2)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
266 return defer.gatherResults([d, self.client.deferred])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
267
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
268
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
269 def test_subscribeTwiceGetNotification(self):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
270
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
271 def onNotification1(data, headers):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
272 d = client1.stopService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
273 d.chainDeferred(client1.deferred)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
274
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
275 def onNotification2(data, headers):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
276 d = client2.stopService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
277 d.chainDeferred(client2.deferred)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
278
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
279 def cb(response):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
280 xmppURI = response['uri']
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
281 d = client1.subscribe(xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
282 d.addCallback(lambda _: xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
283 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
284
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
285 def cb2(xmppURI):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
286 d = client2.subscribe(xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
287 d.addCallback(lambda _: xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
288 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
289
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
290 def cb3(xmppURI):
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
291 d = self.client.publish(TEST_ENTRY, xmppURI)
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
292 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
293
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
294
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
295 client1 = gateway.GatewayClient(baseURI, callbackPort=8088)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
296 client1.startService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
297 client1.callback = onNotification1
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
298 client1.deferred = defer.Deferred()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
299 client2 = gateway.GatewayClient(baseURI, callbackPort=8089)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
300 client2.startService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
301 client2.callback = onNotification2
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
302 client2.deferred = defer.Deferred()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
303
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
304 d = self.client.create()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
305 d.addCallback(cb)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
306 d.addCallback(cb2)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
307 d.addCallback(cb3)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
308 dl = defer.gatherResults([d, client1.deferred, client2.deferred])
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
309 return dl
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
310
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
311
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
312 def test_subscribeGetDelayedNotification(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
313
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
314 def onNotification(data, headers):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
315 self.client.deferred.callback(None)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
316
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
317 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
318 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
319 self.assertNot(self.client.deferred.called)
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
320 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
321 d.addCallback(lambda _: xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
322 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
323
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
324 def cb2(xmppURI):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
325 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
326 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
327
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
328
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
329 self.client.callback = onNotification
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
330 self.client.deferred = defer.Deferred()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
331 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
332 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
333 d.addCallback(cb2)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
334 return defer.gatherResults([d, self.client.deferred])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
335
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
336 def test_subscribeGetDelayedNotification2(self):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
337 """
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
338 Test that subscribing as second results in a notification being sent.
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
339 """
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
340
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
341 def onNotification1(data, headers):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
342 client1.deferred.callback(None)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
343 client1.stopService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
344
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
345 def onNotification2(data, headers):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
346 client2.deferred.callback(None)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
347 client2.stopService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
348
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
349 def cb(response):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
350 xmppURI = response['uri']
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
351 self.assertNot(client1.deferred.called)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
352 self.assertNot(client2.deferred.called)
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
353 d = self.client.publish(TEST_ENTRY, xmppURI)
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
354 d.addCallback(lambda _: xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
355 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
356
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
357 def cb2(xmppURI):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
358 d = client1.subscribe(xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
359 d.addCallback(lambda _: xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
360 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
361
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
362 def cb3(xmppURI):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
363 d = client2.subscribe(xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
364 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
365
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
366 client1 = gateway.GatewayClient(baseURI, callbackPort=8088)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
367 client1.startService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
368 client1.callback = onNotification1
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
369 client1.deferred = defer.Deferred()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
370 client2 = gateway.GatewayClient(baseURI, callbackPort=8089)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
371 client2.startService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
372 client2.callback = onNotification2
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
373 client2.deferred = defer.Deferred()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
374
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
375
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
376 d = self.client.create()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
377 d.addCallback(cb)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
378 d.addCallback(cb2)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
379 d.addCallback(cb3)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
380 dl = defer.gatherResults([d, client1.deferred, client2.deferred])
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
381 return dl
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
382
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
383
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
384 def test_subscribeNonExisting(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
385 def cb(err):
191
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
386 self.assertEqual('403', err.status)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
387
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
388 d = self.client.subscribe('xmpp:%s?node=test' % componentJID)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
389 self.assertFailure(d, error.Error)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
390 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
391 return d
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
392
186
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
393
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
394 def test_subscribeRootGetNotification(self):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
395
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
396 def onNotification(data, headers):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
397 self.client.deferred.callback(None)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
398
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
399 def cb(response):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
400 xmppURI = response['uri']
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
401 jid, nodeIdentifier = gateway.getServiceAndNode(xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
402 rootNode = gateway.getXMPPURI(jid, '')
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
403
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
404 d = self.client.subscribe(rootNode)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
405 d.addCallback(lambda _: xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
406 return d
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
407
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
408 def cb2(xmppURI):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
409 return self.client.publish(TEST_ENTRY, xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
410
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
411
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
412 self.client.callback = onNotification
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
413 self.client.deferred = defer.Deferred()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
414 d = self.client.create()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
415 d.addCallback(cb)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
416 d.addCallback(cb2)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
417 return defer.gatherResults([d, self.client.deferred])
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
418
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
419
191
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
420 def test_unsubscribeNonExisting(self):
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
421 def cb(err):
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
422 self.assertEqual('403', err.status)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
423
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
424 d = self.client.unsubscribe('xmpp:%s?node=test' % componentJID)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
425 self.assertFailure(d, error.Error)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
426 d.addCallback(cb)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
427 return d
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
428
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
429
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
430 def test_items(self):
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
431 def cb(response):
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
432 xmppURI = response['uri']
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
433 d = self.client.items(xmppURI)
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
434 return d
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
435
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
436 d = self.client.publish(TEST_ENTRY)
186
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
437 d.addCallback(cb)
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
438 return d
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
439
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
440
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
441 def test_itemsMaxItems(self):
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
442 def cb(response):
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
443 xmppURI = response['uri']
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
444 d = self.client.items(xmppURI, 2)
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
445 return d
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
446
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
447 d = self.client.publish(TEST_ENTRY)
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
448 d.addCallback(cb)
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
449 return d