comparison idavoll/test/test_gateway.py @ 191:48245777acea

Return proper HTTP status codes on failed un-/subscription.
author Ralph Meijer <ralphm@ik.nu>
date Sat, 17 May 2008 18:31:31 +0000
parents 69cdd8c6a431
children e404775b12df
comparison
equal deleted inserted replaced
190:6e6c89eca9db 191:48245777acea
22 entry.addElement("id", content="urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a") 22 entry.addElement("id", content="urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a")
23 entry.addElement("title", content="Atom-Powered Robots Run Amok") 23 entry.addElement("title", content="Atom-Powered Robots Run Amok")
24 entry.addElement("author").addElement("name", content="John Doe") 24 entry.addElement("author").addElement("name", content="John Doe")
25 entry.addElement("content", content="Some text.") 25 entry.addElement("content", content="Some text.")
26 26
27 #baseURI = "http://pubsub-test.ik.nu/"
28 baseURI = "http://localhost:8086/" 27 baseURI = "http://localhost:8086/"
29 componentJID = "test.ik.nu" 28 componentJID = "pubsub.localhost"
30 29
31 class GatewayTest(unittest.TestCase): 30 class GatewayTest(unittest.TestCase):
32 timeout = 2 31 timeout = 2
33 32
34 def setUp(self): 33 def setUp(self):
189 return dl 188 return dl
190 189
191 190
192 def test_subscribeNonExisting(self): 191 def test_subscribeNonExisting(self):
193 def cb(err): 192 def cb(err):
194 self.assertEqual('404', err.status) 193 self.assertEqual('403', err.status)
195 194
196 d = self.client.subscribe('xmpp:%s?node=test' % componentJID) 195 d = self.client.subscribe('xmpp:%s?node=test' % componentJID)
197 self.assertFailure(d, error.Error) 196 self.assertFailure(d, error.Error)
198 d.addCallback(cb) 197 d.addCallback(cb)
199 return d 198 return d
200 199
201 200
201 def test_unsubscribeNonExisting(self):
202 def cb(err):
203 self.assertEqual('403', err.status)
204
205 d = self.client.unsubscribe('xmpp:%s?node=test' % componentJID)
206 self.assertFailure(d, error.Error)
207 d.addCallback(cb)
208 return d
209
210
202 def test_items(self): 211 def test_items(self):
203 def cb(response): 212 def cb(response):
204 xmppURI = response['uri'] 213 xmppURI = response['uri']
205 d = self.client.items(xmppURI) 214 d = self.client.items(xmppURI)
206 return d 215 return d