annotate idavoll/test/test_backend.py @ 171:bc269696ef42

Reply with the correct error condition on subscription when not subscribed. Author: ralphm. Fixes #7.
author Ralph Meijer <ralphm@ik.nu>
date Thu, 03 Jan 2008 13:10:25 +0000
parents e2c2c2baf483
children 9bfb00edd0cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
171
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
1 # Copyright (c) 2003-2008 Ralph Meijer
155
5191ba7c4df8 Work towards first release 0.5.0.
Ralph Meijer <ralphm@ik.nu>
parents: 143
diff changeset
2 # See LICENSE for details.
5191ba7c4df8 Work towards first release 0.5.0.
Ralph Meijer <ralphm@ik.nu>
parents: 143
diff changeset
3
167
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
4 """
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
5 Tests for L{idavoll.backend}.
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
6 """
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
7
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
8 from twisted.internet import defer
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
9 from twisted.trial import unittest
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
10 from twisted.words.protocols.jabber import jid
171
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
11 from twisted.words.protocols.jabber.error import StanzaError
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
12
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
13 from wokkel import pubsub
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
14
171
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
15 from idavoll import backend, error
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
16
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
17 OWNER = jid.JID('owner@example.com')
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
18
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
19 class BackendTest(unittest.TestCase):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
20 def test_delete_node(self):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
21 class testNode:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
22 id = 'to-be-deleted'
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
23 def get_affiliation(self, entity):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
24 if entity is OWNER:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
25 return defer.succeed('owner')
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
26
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
27 class testStorage:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
28 def get_node(self, node_id):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
29 return defer.succeed(testNode())
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
30
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
31 def delete_node(self, node_id):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
32 if node_id in ['to-be-deleted']:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
33 self.delete_called = True
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
34 return defer.succeed(None)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
35 else:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
36 return defer.fail(error.NodeNotFound())
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
37
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
38 def pre_delete(node_id):
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
39 self.pre_delete_called = True
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
40 return defer.succeed(None)
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
41
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
42 def cb(result):
167
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
43 self.assertTrue(self.pre_delete_called)
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
44 self.assertTrue(self.storage.delete_called)
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
45
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
46 self.storage = testStorage()
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
47 self.backend = backend.BackendService(self.storage)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
48 self.storage.backend = self.backend
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
49
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
50 self.pre_delete_called = False
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
51 self.delete_called = False
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
52
143
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
53 self.backend.register_pre_delete(pre_delete)
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
54 d = self.backend.delete_node('to-be-deleted', OWNER)
48244f3c0c93 Initial revision
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
55 d.addCallback(cb)
167
ef22e4150caa Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents: 157
diff changeset
56 return d
168
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
57
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
58 def test_create_nodeNoID(self):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
59 """
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
60 Test creation of a node without a given node identifier.
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
61 """
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
62 class testStorage:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
63 def create_node(self, node_id, requestor):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
64 self.node_id = node_id
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
65 return defer.succeed(None)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
66
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
67 self.storage = testStorage()
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
68 self.backend = backend.BackendService(self.storage)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
69 self.storage.backend = self.backend
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
70
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
71 def checkID(nodeIdentifier):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
72 self.assertNotIdentical(None, nodeIdentifier)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
73 self.assertIdentical(self.storage.node_id, nodeIdentifier)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
74
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
75 d = self.backend.create_node(None, OWNER)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
76 d.addCallback(checkID)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
77 return d
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
78
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
79 def test_publishNoID(self):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
80 """
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
81 Test publish request with an item without a node identifier.
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
82 """
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
83 class testNode:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
84 id = 'node'
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
85 def get_affiliation(self, entity):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
86 if entity is OWNER:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
87 return defer.succeed('owner')
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
88 def get_configuration(self):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
89 return {'pubsub#deliver_payloads': True,
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
90 'pubsub#persist_items': False}
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
91
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
92 class testStorage:
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
93 def get_node(self, node_id):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
94 return defer.succeed(testNode())
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
95
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
96 def checkID(notification):
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
97 self.assertNotIdentical(None, notification['items'][0]['id'])
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
98
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
99 self.storage = testStorage()
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
100 self.backend = backend.BackendService(self.storage)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
101 self.storage.backend = self.backend
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
102
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
103 self.backend.register_notifier(checkID)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
104
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
105 items = [pubsub.Item()]
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
106 d = self.backend.publish('node', items, OWNER)
e2c2c2baf483 Fix use of uuid module now shipping with Python 2.5.
Ralph Meijer <ralphm@ik.nu>
parents: 167
diff changeset
107 return d
171
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
108
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
109
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
110 class PubSubServiceFromBackendTest(unittest.TestCase):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
111
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
112 def test_unsubscribeNotSubscribed(self):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
113 """
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
114 Test unsubscription request when not subscribed.
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
115 """
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
116
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
117 class TestBackend(object):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
118 def supports_publisher_affiliation(self):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
119 return True
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
120
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
121 def supports_outcast_affiliation(self):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
122 return True
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
123
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
124 def supports_persistent_items(self):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
125 return True
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
126
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
127 def supports_instant_nodes(self):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
128 return True
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
129
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
130 def register_notifier(self, observerfn, *args, **kwargs):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
131 return
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
132
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
133 def unsubscribe(self, nodeIdentifier, subscriber, requestor):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
134 return defer.fail(error.NotSubscribed())
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
135
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
136 def cb(e):
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
137 self.assertEquals('unexpected-request', e.condition)
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
138
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
139 s = backend.PubSubServiceFromBackend(TestBackend())
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
140 d = s.unsubscribe(OWNER, 'test.example.org', 'test', OWNER)
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
141 self.assertFailure(d, StanzaError)
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
142 d.addCallback(cb)
bc269696ef42 Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents: 168
diff changeset
143 return d