annotate src/tmp/wokkel/test/test_pubsub.py @ 1655:ad2ad28b8923

quick_frontend: getFeatures is called on profile plug, and saved in host.features
author Goffi <goffi@goffi.org>
date Mon, 23 Nov 2015 23:30:41 +0100
parents 0fb5785b4c63
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1438
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1 # Copyright (c) Ralph Meijer.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # See LICENSE for details.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
5 Tests for L{wokkel.pubsub}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
6 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
7
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
8 from zope.interface import verify
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
9
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
10 from twisted.trial import unittest
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
11 from twisted.internet import defer
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
12 from twisted.words.xish import domish
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
13 from twisted.words.protocols.jabber import error
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
14 from twisted.words.protocols.jabber.jid import JID
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
15 from twisted.words.protocols.jabber.xmlstream import toResponse
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
16
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
17 from wokkel import data_form, disco, iwokkel, shim
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
18 from wokkel.generic import parseXml
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
19 from wokkel.test.helpers import TestableRequestHandlerMixin, XmlStreamStub
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
20
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
21 from sat.tmp.wokkel import pubsub
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
22
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
23 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
24 NS_PUBSUB_NODE_CONFIG = 'http://jabber.org/protocol/pubsub#node_config'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
25 NS_PUBSUB_ERRORS = 'http://jabber.org/protocol/pubsub#errors'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
26 NS_PUBSUB_EVENT = 'http://jabber.org/protocol/pubsub#event'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
27 NS_PUBSUB_OWNER = 'http://jabber.org/protocol/pubsub#owner'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
28 NS_PUBSUB_META_DATA = 'http://jabber.org/protocol/pubsub#meta-data'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
29 NS_PUBSUB_SUBSCRIBE_OPTIONS = 'http://jabber.org/protocol/pubsub#subscribe_options'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
30
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
31 def calledAsync(fn):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
32 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
33 Function wrapper that fires a deferred upon calling the given function.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
34 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
35 d = defer.Deferred()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
36
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
37 def func(*args, **kwargs):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
38 try:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
39 result = fn(*args, **kwargs)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
40 except:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
41 d.errback()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
42 else:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
43 d.callback(result)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
44
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
45 return d, func
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
46
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
47
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
48 class SubscriptionTest(unittest.TestCase):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
49 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
50 Tests for L{pubsub.Subscription}.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
51 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
52
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
53 def test_fromElement(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
54 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
55 fromElement parses a subscription from XML DOM.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
56 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
57 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
58 <subscription node='test' jid='user@example.org/Home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
59 subscription='pending'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
60 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
61 subscription = pubsub.Subscription.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
62 self.assertEqual('test', subscription.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
63 self.assertEqual(JID('user@example.org/Home'), subscription.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
64 self.assertEqual('pending', subscription.state)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
65 self.assertIdentical(None, subscription.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
66
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
67
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
68 def test_fromElementWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
69 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
70 A subscription identifier in the subscription should be parsed, too.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
71 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
72 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
73 <subscription node='test' jid='user@example.org/Home' subid='1234'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
74 subscription='pending'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
75 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
76 subscription = pubsub.Subscription.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
77 self.assertEqual('1234', subscription.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
78
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
79
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
80 def test_toElement(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
81 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
82 Rendering a Subscription should yield the proper attributes.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
83 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
84 subscription = pubsub.Subscription('test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
85 JID('user@example.org/Home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
86 'pending')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
87 element = subscription.toElement()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
88 self.assertEqual('subscription', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
89 self.assertEqual(None, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
90 self.assertEqual('test', element.getAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
91 self.assertEqual('user@example.org/Home', element.getAttribute('jid'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
92 self.assertEqual('pending', element.getAttribute('subscription'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
93 self.assertFalse(element.hasAttribute('subid'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
94
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
95
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
96 def test_toElementEmptyNodeIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
97 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
98 The empty node identifier should not yield a node attribute.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
99 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
100 subscription = pubsub.Subscription('',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
101 JID('user@example.org/Home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
102 'pending')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
103 element = subscription.toElement()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
104 self.assertFalse(element.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
105
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
106
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
107 def test_toElementWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
108 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
109 The subscription identifier, if set, is in the subid attribute.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
110 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
111 subscription = pubsub.Subscription('test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
112 JID('user@example.org/Home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
113 'pending',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
114 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
115 element = subscription.toElement()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
116 self.assertEqual('1234', element.getAttribute('subid'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
117
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
118
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
119
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
120 class PubSubClientTest(unittest.TestCase):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
121 timeout = 2
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
122
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
123 def setUp(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
124 self.stub = XmlStreamStub()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
125 self.protocol = pubsub.PubSubClient()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
126 self.protocol.xmlstream = self.stub.xmlstream
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
127 self.protocol.connectionInitialized()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
128
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
129
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
130 def test_interface(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
131 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
132 Do instances of L{pubsub.PubSubClient} provide L{iwokkel.IPubSubClient}?
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
133 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
134 verify.verifyObject(iwokkel.IPubSubClient, self.protocol)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
135
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
136
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
137 def test_eventItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
138 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
139 Test receiving an items event resulting in a call to itemsReceived.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
140 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
141 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
142 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
143 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
144 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
145 items = event.addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
146 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
147 item1 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
148 item1['id'] = 'item1'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
149 item2 = items.addElement('retract')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
150 item2['id'] = 'item2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
151 item3 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
152 item3['id'] = 'item3'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
153
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
154 def itemsReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
155 self.assertEquals(JID('user@example.org/home'), event.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
156 self.assertEquals(JID('pubsub.example.org'), event.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
157 self.assertEquals('test', event.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
158 self.assertEquals([item1, item2, item3], event.items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
159
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
160 d, self.protocol.itemsReceived = calledAsync(itemsReceived)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
161 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
162 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
163
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
164
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
165 def test_eventItemsCollection(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
166 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
167 Test receiving an items event resulting in a call to itemsReceived.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
168 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
169 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
170 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
171 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
172 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
173 items = event.addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
174 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
175
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
176 headers = shim.Headers([('Collection', 'collection')])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
177 message.addChild(headers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
178
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
179 def itemsReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
180 self.assertEquals(JID('user@example.org/home'), event.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
181 self.assertEquals(JID('pubsub.example.org'), event.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
182 self.assertEquals('test', event.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
183 self.assertEquals({'Collection': ['collection']}, event.headers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
184
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
185 d, self.protocol.itemsReceived = calledAsync(itemsReceived)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
186 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
187 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
188
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
189
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
190 def test_eventItemsError(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
191 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
192 An error message with embedded event should not be handled.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
193
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
194 This test uses an items event, which should not result in itemsReceived
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
195 being called. In general message.handled should be False.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
196 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
197 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
198 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
199 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
200 message['type'] = 'error'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
201 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
202 items = event.addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
203 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
204
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
205 class UnexpectedCall(Exception):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
206 pass
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
207
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
208 def itemsReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
209 raise UnexpectedCall("Unexpected call to itemsReceived")
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
210
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
211 self.protocol.itemsReceived = itemsReceived
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
212 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
213 self.assertFalse(message.handled)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
214
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
215
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
216 def test_eventDelete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
217 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
218 Test receiving a delete event resulting in a call to deleteReceived.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
219 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
220 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
221 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
222 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
223 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
224 delete = event.addElement('delete')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
225 delete['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
226
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
227 def deleteReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
228 self.assertEquals(JID('user@example.org/home'), event.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
229 self.assertEquals(JID('pubsub.example.org'), event.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
230 self.assertEquals('test', event.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
231
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
232 d, self.protocol.deleteReceived = calledAsync(deleteReceived)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
233 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
234 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
235
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
236
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
237 def test_eventDeleteRedirect(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
238 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
239 Test receiving a delete event with a redirect URI.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
240 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
241 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
242 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
243 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
244 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
245 delete = event.addElement('delete')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
246 delete['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
247 uri = 'xmpp:pubsub.example.org?;node=test2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
248 delete.addElement('redirect')['uri'] = uri
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
249
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
250 def deleteReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
251 self.assertEquals(JID('user@example.org/home'), event.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
252 self.assertEquals(JID('pubsub.example.org'), event.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
253 self.assertEquals('test', event.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
254 self.assertEquals(uri, event.redirectURI)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
255
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
256 d, self.protocol.deleteReceived = calledAsync(deleteReceived)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
257 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
258 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
259
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
260
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
261 def test_event_purge(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
262 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
263 Test receiving a purge event resulting in a call to purgeReceived.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
264 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
265 message = domish.Element((None, 'message'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
266 message['from'] = 'pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
267 message['to'] = 'user@example.org/home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
268 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
269 items = event.addElement('purge')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
270 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
271
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
272 def purgeReceived(event):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
273 self.assertEquals(JID('user@example.org/home'), event.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
274 self.assertEquals(JID('pubsub.example.org'), event.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
275 self.assertEquals('test', event.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
276
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
277 d, self.protocol.purgeReceived = calledAsync(purgeReceived)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
278 self.stub.send(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
279 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
280
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
281
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
282 def test_createNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
283 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
284 Test sending create request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
285 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
286
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
287 def cb(nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
288 self.assertEquals('test', nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
289
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
290 d = self.protocol.createNode(JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
291 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
292
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
293 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
294 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
295 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
296 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
297 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
298 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
299 'create', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
300 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
301 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
302 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
303
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
304 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
305 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
306 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
307
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
308
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
309 def test_createNodeInstant(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
310 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
311 Test sending create request resulting in an instant node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
312 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
313
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
314 def cb(nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
315 self.assertEquals('test', nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
316
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
317 d = self.protocol.createNode(JID('pubsub.example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
318 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
319
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
320 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
321 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
322 'create', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
323 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
324 self.assertFalse(child.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
325
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
326 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
327 command = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
328 create = command.addElement('create')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
329 create['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
330 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
331 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
332
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
333
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
334 def test_createNodeRenamed(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
335 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
336 Test sending create request resulting in renamed node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
337 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
338
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
339 def cb(nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
340 self.assertEquals('test2', nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
341
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
342 d = self.protocol.createNode(JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
343 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
344
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
345 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
346 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
347 'create', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
348 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
349 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
350
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
351 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
352 command = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
353 create = command.addElement('create')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
354 create['node'] = 'test2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
355 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
356 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
357
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
358
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
359 def test_createNodeWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
360 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
361 Test sending create request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
362 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
363
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
364 d = self.protocol.createNode(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
365 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
366
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
367 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
368 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
369
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
370 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
371 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
372 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
373
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
374
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
375 def test_createNodeWithConfig(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
376 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
377 Test sending create request with configuration options
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
378 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
379
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
380 options = {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
381 'pubsub#title': 'Princely Musings (Atom)',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
382 'pubsub#deliver_payloads': True,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
383 'pubsub#persist_items': '1',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
384 'pubsub#max_items': '10',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
385 'pubsub#access_model': 'open',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
386 'pubsub#type': 'http://www.w3.org/2005/Atom',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
387 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
388
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
389 d = self.protocol.createNode(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
390 sender=JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
391 options=options)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
392
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
393 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
394
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
395 # check if there is exactly one configure element
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
396 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
397 'configure', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
398 self.assertEqual(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
399
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
400 # check that it has a configuration form
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
401 form = data_form.findForm(children[0], NS_PUBSUB_NODE_CONFIG)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
402 self.assertEqual('submit', form.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
403
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
404
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
405 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
406 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
407 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
408
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
409
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
410 def test_deleteNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
411 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
412 Test sending delete request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
413 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
414
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
415 d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
416
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
417 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
418 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
419 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
420 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
421 self.assertEquals(NS_PUBSUB_OWNER, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
422 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
423 'delete', NS_PUBSUB_OWNER))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
424 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
425 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
426 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
427
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
428 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
429 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
430 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
431
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
432
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
433 def test_deleteNodeWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
434 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
435 Test sending delete request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
436 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
437
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
438 d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
439 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
440
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
441 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
442 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
443
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
444 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
445 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
446 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
447
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
448
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
449 def test_publish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
450 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
451 Test sending publish request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
452 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
453
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
454 item = pubsub.Item()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
455 d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
456
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
457 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
458 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
459 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
460 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
461 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
462 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
463 'publish', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
464 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
465 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
466 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
467 items = list(domish.generateElementsQNamed(child.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
468 'item', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
469 self.assertEquals(1, len(items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
470 self.assertIdentical(item, items[0])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
471
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
472 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
473 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
474 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
475
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
476
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
477 def test_publishNoItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
478 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
479 Test sending publish request without items.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
480 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
481
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
482 d = self.protocol.publish(JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
483
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
484 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
485 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
486 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
487 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
488 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
489 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
490 'publish', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
491 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
492 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
493 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
494
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
495 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
496 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
497 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
498
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
499
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
500 def test_publishWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
501 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
502 Test sending publish request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
503 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
504
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
505 item = pubsub.Item()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
506 d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item],
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
507 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
508
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
509 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
510 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
511
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
512 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
513 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
514 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
515
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
516
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
517 def test_subscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
518 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
519 Test sending subscription request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
520 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
521 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
522 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
523
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
524 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
525 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
526 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
527 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
528 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
529 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
530 'subscribe', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
531 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
532 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
533 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
534 self.assertEquals('user@example.org', child['jid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
535
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
536 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
537 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
538 subscription = pubsub.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
539 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
540 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
541 subscription['subscription'] = 'subscribed'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
542 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
543 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
544
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
545
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
546 def test_subscribeReturnsSubscription(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
547 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
548 A successful subscription should return a Subscription instance.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
549 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
550 def cb(subscription):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
551 self.assertEqual(JID('user@example.org'), subscription.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
552
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
553 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
554 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
555 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
556
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
557 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
558
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
559 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
560 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
561 subscription = pubsub.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
562 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
563 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
564 subscription['subscription'] = 'subscribed'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
565 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
566 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
567
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
568
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
569 def test_subscribePending(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
570 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
571 Test sending subscription request that results in a pending
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
572 subscription.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
573 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
574 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
575 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
576
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
577 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
578 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
579 command = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
580 subscription = command.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
581 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
582 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
583 subscription['subscription'] = 'pending'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
584 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
585 self.assertFailure(d, pubsub.SubscriptionPending)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
586 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
587
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
588
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
589 def test_subscribeUnconfigured(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
590 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
591 Test sending subscription request that results in an unconfigured
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
592 subscription.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
593 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
594 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
595 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
596
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
597 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
598 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
599 command = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
600 subscription = command.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
601 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
602 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
603 subscription['subscription'] = 'unconfigured'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
604 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
605 self.assertFailure(d, pubsub.SubscriptionUnconfigured)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
606 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
607
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
608
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
609 def test_subscribeWithOptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
610 options = {'pubsub#deliver': False}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
611
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
612 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
613 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
614 options=options)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
615 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
616
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
617 # Check options present
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
618 childNames = []
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
619 for element in iq.pubsub.elements():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
620 if element.uri == NS_PUBSUB:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
621 childNames.append(element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
622
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
623 self.assertEqual(['subscribe', 'options'], childNames)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
624 form = data_form.findForm(iq.pubsub.options,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
625 NS_PUBSUB_SUBSCRIBE_OPTIONS)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
626 self.assertEqual('submit', form.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
627 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
628 self.assertEqual(options, form.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
629
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
630 # Send response
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
631 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
632 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
633 subscription = pubsub.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
634 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
635 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
636 subscription['subscription'] = 'subscribed'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
637 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
638
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
639 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
640
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
641
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
642 def test_subscribeWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
643 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
644 Test sending subscription request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
645 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
646 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
647 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
648 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
649
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
650 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
651 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
652
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
653 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
654 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
655 subscription = pubsub.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
656 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
657 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
658 subscription['subscription'] = 'subscribed'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
659 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
660 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
661
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
662
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
663 def test_subscribeReturningSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
664 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
665 Test sending subscription request with subscription identifier.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
666 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
667 def cb(subscription):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
668 self.assertEqual('1234', subscription.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
669
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
670 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
671 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
672 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
673
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
674 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
675
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
676 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
677 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
678 subscription = pubsub.addElement('subscription')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
679 subscription['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
680 subscription['jid'] = 'user@example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
681 subscription['subscription'] = 'subscribed'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
682 subscription['subid'] = '1234'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
683 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
684 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
685
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
686
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
687 def test_unsubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
688 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
689 Test sending unsubscription request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
690 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
691 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
692 JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
693
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
694 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
695 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
696 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
697 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
698 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
699 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
700 'unsubscribe', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
701 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
702 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
703 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
704 self.assertEquals('user@example.org', child['jid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
705
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
706 self.stub.send(toResponse(iq, 'result'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
707 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
708
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
709
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
710 def test_unsubscribeWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
711 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
712 Test sending unsubscription request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
713 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
714 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
715 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
716 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
717
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
718 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
719 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
720 self.stub.send(toResponse(iq, 'result'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
721 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
722
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
723
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
724 def test_unsubscribeWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
725 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
726 Test sending unsubscription request with subscription identifier.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
727 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
728 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
729 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
730 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
731
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
732 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
733 child = iq.pubsub.unsubscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
734 self.assertEquals('1234', child['subid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
735
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
736 self.stub.send(toResponse(iq, 'result'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
737 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
738
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
739
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
740 def test_items(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
741 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
742 Test sending items request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
743 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
744 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
745 self.assertEquals([], items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
746
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
747 d = self.protocol.items(JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
748 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
749
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
750 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
751 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
752 self.assertEquals('get', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
753 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
754 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
755 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
756 'items', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
757 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
758 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
759 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
760
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
761 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
762 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
763 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
764
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
765 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
766
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
767 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
768
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
769
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
770 def test_itemsMaxItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
771 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
772 Test sending items request, with limit on the number of items.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
773 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
774 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
775 self.assertEquals(2, len(items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
776 self.assertEquals([item1, item2], items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
777
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
778 d = self.protocol.items(JID('pubsub.example.org'), 'test', maxItems=2)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
779 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
780
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
781 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
782 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
783 self.assertEquals('get', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
784 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
785 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
786 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
787 'items', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
788 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
789 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
790 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
791 self.assertEquals('2', child['max_items'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
792
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
793 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
794 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
795 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
796 item1 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
797 item1['id'] = 'item1'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
798 item2 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
799 item2['id'] = 'item2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
800
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
801 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
802
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
803 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
804
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
805
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
806 def test_itemsWithItemIdentifiers(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
807 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
808 Test sending items request with item identifiers.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
809 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
810 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
811 self.assertEquals(2, len(items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
812 self.assertEquals([item1, item2], items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
813
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
814 d = self.protocol.items(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
815 itemIdentifiers=['item1', 'item2'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
816 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
817
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
818 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
819 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
820 self.assertEquals('get', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
821 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
822 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
823 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
824 'items', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
825 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
826 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
827 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
828 itemIdentifiers = [item.getAttribute('id') for item in
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
829 domish.generateElementsQNamed(child.children, 'item',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
830 NS_PUBSUB)]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
831 self.assertEquals(['item1', 'item2'], itemIdentifiers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
832
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
833 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
834 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
835 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
836 item1 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
837 item1['id'] = 'item1'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
838 item2 = items.addElement('item')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
839 item2['id'] = 'item2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
840
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
841 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
842
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
843 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
844
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
845
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
846 def test_itemsWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
847 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
848 Test sending items request with a subscription identifier.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
849 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
850
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
851 d = self.protocol.items(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
852 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
853
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
854 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
855 child = iq.pubsub.items
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
856 self.assertEquals('1234', child['subid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
857
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
858 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
859 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
860 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
861
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
862 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
863 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
864
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
865
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
866 def test_itemsWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
867 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
868 Test sending items request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
869 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
870
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
871 d = self.protocol.items(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
872 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
873
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
874 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
875 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
876
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
877 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
878 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
879 items['node'] = 'test'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
880
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
881 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
882 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
883
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
884
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
885 def test_retractItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
886 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
887 Test sending items retraction.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
888 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
889 d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
890 itemIdentifiers=['item1', 'item2'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
891
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
892 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
893 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
894 self.assertEquals('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
895 self.assertEquals('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
896 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
897 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
898 'retract', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
899 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
900 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
901 self.assertEquals('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
902 itemIdentifiers = [item.getAttribute('id') for item in
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
903 domish.generateElementsQNamed(child.children, 'item',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
904 NS_PUBSUB)]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
905 self.assertEquals(['item1', 'item2'], itemIdentifiers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
906
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
907 self.stub.send(toResponse(iq, 'result'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
908 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
909
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
910
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
911 def test_retractItemsWithSender(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
912 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
913 Test retracting items request from a specific JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
914 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
915 d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
916 itemIdentifiers=['item1', 'item2'],
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
917 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
918
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
919 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
920 self.assertEquals('user@example.org', iq['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
921
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
922 self.stub.send(toResponse(iq, 'result'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
923 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
924
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
925
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
926 def test_getOptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
927 def cb(form):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
928 self.assertEqual('form', form.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
929 self.assertEqual(NS_PUBSUB_SUBSCRIBE_OPTIONS, form.formNamespace)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
930 field = form.fields['pubsub#deliver']
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
931 self.assertEqual('boolean', field.fieldType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
932 self.assertIdentical(True, field.value)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
933 self.assertEqual('Enable delivery?', field.label)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
934
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
935 d = self.protocol.getOptions(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
936 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
937 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
938 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
939
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
940 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
941 self.assertEqual('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
942 self.assertEqual('get', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
943 self.assertEqual('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
944 self.assertEqual(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
945 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
946 'options', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
947 self.assertEqual(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
948 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
949 self.assertEqual('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
950
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
951 self.assertEqual(0, len(child.children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
952
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
953 # Send response
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
954 form = data_form.Form('form', formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
955 form.addField(data_form.Field('boolean', var='pubsub#deliver',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
956 label='Enable delivery?',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
957 value=True))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
958 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
959 response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
960 response.pubsub.addElement('options')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
961 response.pubsub.options.addChild(form.toElement())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
962 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
963
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
964 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
965
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
966
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
967 def test_getOptionsWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
968 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
969 Getting options with a subid should have the subid in the request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
970 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
971
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
972 d = self.protocol.getOptions(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
973 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
974 sender=JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
975 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
976
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
977 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
978 child = iq.pubsub.options
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
979 self.assertEqual('1234', child['subid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
980
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
981 # Send response
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
982 form = data_form.Form('form', formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
983 form.addField(data_form.Field('boolean', var='pubsub#deliver',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
984 label='Enable delivery?',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
985 value=True))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
986 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
987 response.addElement((NS_PUBSUB, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
988 response.pubsub.addElement('options')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
989 response.pubsub.options.addChild(form.toElement())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
990 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
991
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
992 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
993
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
994
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
995 def test_setOptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
996 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
997 setOptions should send out a options-set request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
998 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
999 options = {'pubsub#deliver': False}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1000
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1001 d = self.protocol.setOptions(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1002 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1003 options,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1004 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1005
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1006 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1007 self.assertEqual('pubsub.example.org', iq.getAttribute('to'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1008 self.assertEqual('set', iq.getAttribute('type'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1009 self.assertEqual('pubsub', iq.pubsub.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1010 self.assertEqual(NS_PUBSUB, iq.pubsub.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1011 children = list(domish.generateElementsQNamed(iq.pubsub.children,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1012 'options', NS_PUBSUB))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1013 self.assertEqual(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1014 child = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1015 self.assertEqual('test', child['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1016
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1017 form = data_form.findForm(child, NS_PUBSUB_SUBSCRIBE_OPTIONS)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1018 self.assertEqual('submit', form.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1019 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1020 self.assertEqual(options, form.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1021
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1022 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1023 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1024
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1025 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1026
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1027
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1028 def test_setOptionsWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1029 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1030 setOptions should send out a options-set request with subid.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1031 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1032 options = {'pubsub#deliver': False}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1033
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1034 d = self.protocol.setOptions(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1035 JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1036 options,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1037 subscriptionIdentifier='1234',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1038 sender=JID('user@example.org'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1039
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1040 iq = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1041 child = iq.pubsub.options
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1042 self.assertEqual('1234', child['subid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1043
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1044 form = data_form.findForm(child, NS_PUBSUB_SUBSCRIBE_OPTIONS)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1045 self.assertEqual('submit', form.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1046 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1047 self.assertEqual(options, form.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1048
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1049 response = toResponse(iq, 'result')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1050 self.stub.send(response)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1051
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1052 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1053
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1054
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1055 class PubSubRequestTest(unittest.TestCase):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1056
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1057 def test_fromElementUnknown(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1058 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1059 An unknown verb raises NotImplementedError.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1060 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1061
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1062 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1063 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1064 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1065 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1066 <non-existing-verb/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1067 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1068 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1069 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1070
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1071 self.assertRaises(NotImplementedError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1072 pubsub.PubSubRequest.fromElement, parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1073
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1074
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1075 def test_fromElementKnownBadCombination(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1076 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1077 Multiple verbs in an unknown configuration raises NotImplementedError.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1078 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1079
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1080 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1081 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1082 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1083 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1084 <publish/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1085 <create/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1086 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1087 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1088 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1089
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1090 self.assertRaises(NotImplementedError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1091 pubsub.PubSubRequest.fromElement, parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1092
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1093 def test_fromElementPublish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1094 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1095 Test parsing a publish request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1096 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1097
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1098 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1099 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1100 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1101 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1102 <publish node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1103 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1104 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1105 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1106
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1107 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1108 self.assertEqual('publish', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1109 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1110 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1111 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1112 self.assertEqual([], request.items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1113
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1114
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1115 def test_fromElementPublishItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1116 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1117 Test parsing a publish request with items.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1118 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1119
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1120 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1121 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1122 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1123 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1124 <publish node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1125 <item id="item1"/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1126 <item id="item2"/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1127 </publish>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1128 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1129 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1130 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1131
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1132 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1133 self.assertEqual(2, len(request.items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1134 self.assertEqual(u'item1', request.items[0]["id"])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1135 self.assertEqual(u'item2', request.items[1]["id"])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1136
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1137
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1138 def test_fromElementPublishItemsOptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1139 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1140 Test parsing a publish request with items and options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1141
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1142 Note that publishing options are not supported, but passing them
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1143 shouldn't affect processing of the publish request itself.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1144 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1145
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1146 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1147 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1148 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1149 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1150 <publish node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1151 <item id="item1"/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1152 <item id="item2"/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1153 </publish>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1154 <publish-options/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1155 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1156 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1157 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1158
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1159 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1160 self.assertEqual(2, len(request.items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1161 self.assertEqual(u'item1', request.items[0]["id"])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1162 self.assertEqual(u'item2', request.items[1]["id"])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1163
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1164 def test_fromElementPublishNoNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1165 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1166 A publish request to the root node should raise an exception.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1167 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1168 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1169 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1170 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1171 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1172 <publish/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1173 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1174 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1175 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1176
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1177 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1178 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1179 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1180 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1181 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1182 self.assertEqual('nodeid-required', err.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1183
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1184
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1185 def test_fromElementSubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1186 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1187 Test parsing a subscription request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1188 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1189
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1190 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1191 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1192 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1193 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1194 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1195 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1196 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1197 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1198
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1199 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1200 self.assertEqual('subscribe', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1201 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1202 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1203 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1204 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1205
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1206
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1207 def test_fromElementSubscribeEmptyNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1208 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1209 Test parsing a subscription request to the root node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1210 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1211
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1212 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1213 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1214 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1215 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1216 <subscribe jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1217 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1218 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1219 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1220
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1221 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1222 self.assertEqual('', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1223
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1224
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1225 def test_fromElementSubscribeNoJID(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1226 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1227 Subscribe requests without a JID should raise a bad-request exception.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1228 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1229 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1230 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1231 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1232 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1233 <subscribe node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1234 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1235 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1236 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1237 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1238 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1239 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1240 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1241 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1242 self.assertEqual('jid-required', err.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1243
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1244
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1245 def test_fromElementSubscribeWithOptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1246 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1247 Test parsing a subscription request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1248 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1249
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1250 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1251 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1252 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1253 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1254 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1255 <options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1256 <x xmlns="jabber:x:data" type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1257 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1258 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1259 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1260 <field var='pubsub#deliver' type='boolean'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1261 label='Enable delivery?'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1262 <value>1</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1263 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1264 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1265 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1266 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1267 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1268 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1269
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1270 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1271 self.assertEqual('subscribe', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1272 request.options.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1273 self.assertEqual({'pubsub#deliver': True}, request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1274
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1275
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1276 def test_fromElementSubscribeWithOptionsBadFormType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1277 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1278 The options form should have the right type.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1279 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1280
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1281 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1282 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1283 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1284 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1285 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1286 <options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1287 <x xmlns="jabber:x:data" type='result'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1288 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1289 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1290 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1291 <field var='pubsub#deliver' type='boolean'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1292 label='Enable delivery?'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1293 <value>1</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1294 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1295 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1296 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1297 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1298 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1299 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1300
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1301 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1302 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1303 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1304 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1305 self.assertEqual("Unexpected form type 'result'", err.text)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1306 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1307
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1308
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1309 def test_fromElementSubscribeWithOptionsEmpty(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1310 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1311 When no (suitable) form is found, the options are empty.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1312 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1313
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1314 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1315 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1316 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1317 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1318 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1319 <options/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1320 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1321 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1322 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1323
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1324 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1325 self.assertEqual('subscribe', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1326 self.assertEqual({}, request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1327
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1328
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1329 def test_fromElementUnsubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1330 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1331 Test parsing an unsubscription request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1332 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1333
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1334 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1335 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1336 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1337 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1338 <unsubscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1339 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1340 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1341 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1342
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1343 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1344 self.assertEqual('unsubscribe', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1345 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1346 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1347 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1348 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1349
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1350
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1351 def test_fromElementUnsubscribeWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1352 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1353 Test parsing an unsubscription request with subscription identifier.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1354 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1355
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1356 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1357 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1358 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1359 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1360 <unsubscribe node='test' jid='user@example.org/Home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1361 subid='1234'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1362 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1363 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1364 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1365
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1366 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1367 self.assertEqual('1234', request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1368
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1369
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1370 def test_fromElementUnsubscribeNoJID(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1371 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1372 Unsubscribe requests without a JID should raise a bad-request exception.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1373 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1374 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1375 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1376 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1377 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1378 <unsubscribe node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1379 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1380 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1381 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1382 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1383 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1384 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1385 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1386 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1387 self.assertEqual('jid-required', err.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1388
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1389
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1390 def test_fromElementOptionsGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1391 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1392 Test parsing a request for getting subscription options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1393 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1394
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1395 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1396 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1397 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1398 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1399 <options node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1400 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1401 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1402 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1403
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1404 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1405 self.assertEqual('optionsGet', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1406 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1407 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1408 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1409 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1410
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1411
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1412 def test_fromElementOptionsGetWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1413 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1414 Test parsing a request for getting subscription options with subid.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1415 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1416
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1417 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1418 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1419 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1420 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1421 <options node='test' jid='user@example.org/Home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1422 subid='1234'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1423 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1424 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1425 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1426
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1427 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1428 self.assertEqual('1234', request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1429
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1430
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1431 def test_fromElementOptionsSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1432 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1433 Test parsing a request for setting subscription options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1434 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1435
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1436 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1437 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1438 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1439 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1440 <options node='test' jid='user@example.org/Home'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1441 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1442 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1443 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1444 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1445 <field var='pubsub#deliver'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1446 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1447 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1448 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1449 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1450 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1451
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1452 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1453 self.assertEqual('optionsSet', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1454 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1455 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1456 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1457 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1458 self.assertEqual({'pubsub#deliver': '1'}, request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1459
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1460
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1461 def test_fromElementOptionsSetWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1462 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1463 Test parsing a request for setting subscription options with subid.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1464 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1465
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1466 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1467 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1468 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1469 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1470 <options node='test' jid='user@example.org/Home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1471 subid='1234'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1472 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1473 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1474 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1475 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1476 <field var='pubsub#deliver'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1477 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1478 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1479 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1480 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1481 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1482
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1483 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1484 self.assertEqual('1234', request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1485
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1486
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1487 def test_fromElementOptionsSetCancel(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1488 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1489 Test parsing a request for cancelling setting subscription options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1490 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1491
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1492 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1493 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1494 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1495 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1496 <options node='test' jid='user@example.org/Home'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1497 <x xmlns='jabber:x:data' type='cancel'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1498 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1499 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1500 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1501 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1502
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1503 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1504 self.assertEqual('cancel', request.options.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1505
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1506
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1507 def test_fromElementOptionsSetBadFormType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1508 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1509 On a options set request unknown fields should be ignored.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1510 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1511
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1512 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1513 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1514 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1515 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1516 <options node='test' jid='user@example.org/Home'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1517 <x xmlns='jabber:x:data' type='result'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1518 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1519 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1520 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1521 <field var='pubsub#deliver'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1522 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1523 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1524 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1525 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1526 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1527
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1528 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1529 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1530 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1531 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1532 self.assertEqual("Unexpected form type 'result'", err.text)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1533 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1534
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1535
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1536 def test_fromElementOptionsSetNoForm(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1537 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1538 On a options set request a form is required.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1539 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1540
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1541 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1542 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1543 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1544 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1545 <options node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1546 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1547 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1548 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1549 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1550 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1551 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1552 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1553 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1554
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1555
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1556 def test_fromElementSubscriptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1557 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1558 Test parsing a request for all subscriptions.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1559 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1560
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1561 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1562 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1563 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1564 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1565 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1566 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1567 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1568 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1569
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1570 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1571 self.assertEqual('subscriptions', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1572 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1573 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1574
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1575
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1576 def test_fromElementAffiliations(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1577 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1578 Test parsing a request for all affiliations.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1579 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1580
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1581 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1582 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1583 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1584 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1585 <affiliations/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1586 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1587 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1588 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1589
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1590 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1591 self.assertEqual('affiliations', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1592 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1593 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1594
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1595
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1596 def test_fromElementCreate(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1597 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1598 Test parsing a request to create a node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1599 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1600
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1601 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1602 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1603 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1604 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1605 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1606 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1607 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1608 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1609
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1610 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1611 self.assertEqual('create', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1612 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1613 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1614 self.assertEqual('mynode', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1615 self.assertIdentical(None, request.options)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1616
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1617
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1618 def test_fromElementCreateInstant(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1619 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1620 Test parsing a request to create an instant node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1621 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1622
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1623 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1624 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1625 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1626 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1627 <create/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1628 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1629 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1630 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1631
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1632 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1633 self.assertIdentical(None, request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1634
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1635
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1636 def test_fromElementCreateConfigureEmpty(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1637 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1638 Test parsing a request to create a node with an empty configuration.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1639 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1640
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1641 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1642 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1643 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1644 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1645 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1646 <configure/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1647 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1648 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1649 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1650
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1651 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1652 self.assertEqual({}, request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1653 self.assertEqual(u'mynode', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1654
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1655
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1656 def test_fromElementCreateConfigureEmptyWrongOrder(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1657 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1658 Test parsing a request to create a node and configure, wrong order.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1659
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1660 The C{configure} element should come after the C{create} request,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1661 but we should accept both orders.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1662 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1663
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1664 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1665 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1666 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1667 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1668 <configure/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1669 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1670 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1671 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1672 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1673
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1674 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1675 self.assertEqual({}, request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1676 self.assertEqual(u'mynode', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1677
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1678
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1679 def test_fromElementCreateConfigure(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1680 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1681 Test parsing a request to create a node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1682 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1683
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1684 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1685 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1686 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1687 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1688 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1689 <configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1690 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1691 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1692 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1693 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1694 <field var='pubsub#access_model'><value>open</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1695 <field var='pubsub#persist_items'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1696 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1697 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1698 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1699 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1700 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1701
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1702 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1703 values = request.options
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1704 self.assertIn('pubsub#access_model', values)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1705 self.assertEqual(u'open', values['pubsub#access_model'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1706 self.assertIn('pubsub#persist_items', values)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1707 self.assertEqual(u'0', values['pubsub#persist_items'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1708
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1709
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1710 def test_fromElementCreateConfigureBadFormType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1711 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1712 The form of a node creation request should have the right type.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1713 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1714
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1715 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1716 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1717 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1718 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1719 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1720 <configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1721 <x xmlns='jabber:x:data' type='result'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1722 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1723 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1724 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1725 <field var='pubsub#access_model'><value>open</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1726 <field var='pubsub#persist_items'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1727 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1728 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1729 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1730 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1731 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1732
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1733 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1734 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1735 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1736 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1737 self.assertEqual("Unexpected form type 'result'", err.text)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1738 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1739
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1740
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1741 def test_fromElementDefault(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1742 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1743 Parsing default node configuration request sets required attributes.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1744
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1745 Besides C{verb}, C{sender} and C{recipient}, we expect C{nodeType}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1746 to be set. If not passed it receives the default C{u'leaf'}.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1747 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1748
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1749 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1750 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1751 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1752 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1753 <default/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1754 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1755 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1756 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1757
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1758 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1759 self.assertEquals(u'default', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1760 self.assertEquals(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1761 self.assertEquals(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1762 self.assertEquals(u'leaf', request.nodeType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1763
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1764
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1765 def test_fromElementDefaultCollection(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1766 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1767 Parsing default request for collection sets nodeType to collection.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1768 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1769
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1770 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1771 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1772 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1773 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1774 <default>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1775 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1776 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1777 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1778 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1779 <field var='pubsub#node_type'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1780 <value>collection</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1781 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1782 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1783 </default>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1784
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1785 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1786 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1787 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1788
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1789 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1790 self.assertEquals('collection', request.nodeType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1791
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1792
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1793 def test_fromElementConfigureGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1794 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1795 Test parsing a node configuration get request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1796 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1797
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1798 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1799 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1800 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1801 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1802 <configure node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1803 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1804 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1805 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1806
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1807 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1808 self.assertEqual('configureGet', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1809 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1810 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1811 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1812
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1813
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1814 def test_fromElementConfigureSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1815 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1816 On a node configuration set request the Data Form is parsed.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1817 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1818
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1819 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1820 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1821 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1822 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1823 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1824 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1825 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1826 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1827 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1828 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1829 <field var='pubsub#persist_items'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1830 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1831 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1832 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1833 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1834 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1835
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1836 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1837 self.assertEqual('configureSet', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1838 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1839 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1840 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1841 self.assertEqual({'pubsub#deliver_payloads': '0',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1842 'pubsub#persist_items': '1'},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1843 request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1844
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1845
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1846 def test_fromElementConfigureSetCancel(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1847 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1848 The node configuration is cancelled, so no options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1849 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1850
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1851 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1852 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1853 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1854 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1855 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1856 <x xmlns='jabber:x:data' type='cancel'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1857 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1858 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1859 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1860 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1861
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1862 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1863 self.assertEqual('cancel', request.options.formType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1864
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1865
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1866 def test_fromElementConfigureSetBadFormType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1867 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1868 The form of a node configuraton set request should have the right type.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1869 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1870
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1871 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1872 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1873 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1874 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1875 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1876 <x xmlns='jabber:x:data' type='result'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1877 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1878 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1879 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1880 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1881 <field var='x-myfield'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1882 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1883 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1884 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1885 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1886 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1887
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1888 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1889 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1890 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1891 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1892 self.assertEqual("Unexpected form type 'result'", err.text)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1893 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1894
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1895
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1896 def test_fromElementConfigureSetNoForm(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1897 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1898 On a node configuration set request a form is required.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1899 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1900
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1901 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1902 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1903 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1904 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1905 <configure node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1906 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1907 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1908 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1909 err = self.assertRaises(error.StanzaError,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1910 pubsub.PubSubRequest.fromElement,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1911 parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1912 self.assertEqual('bad-request', err.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1913 self.assertEqual(None, err.appCondition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1914
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1915
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1916 def test_fromElementItems(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1917 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1918 Test parsing an items request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1919 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1920 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1921 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1922 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1923 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1924 <items node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1925 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1926 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1927 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1928
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1929 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1930 self.assertEqual('items', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1931 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1932 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1933 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1934 self.assertIdentical(None, request.maxItems)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1935 self.assertIdentical(None, request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1936 self.assertEqual([], request.itemIdentifiers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1937
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1938
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1939 def test_fromElementItemsSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1940 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1941 Test parsing an items request with subscription identifier.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1942 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1943 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1944 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1945 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1946 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1947 <items node='test' subid='1234'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1948 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1949 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1950 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1951
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1952 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1953 self.assertEqual('1234', request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1954
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1955
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1956 def test_fromElementRetract(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1957 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1958 Test parsing a retract request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1959 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1960
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1961 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1962 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1963 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1964 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1965 <retract node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1966 <item id='item1'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1967 <item id='item2'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1968 </retract>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1969 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1970 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1971 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1972
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1973 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1974 self.assertEqual('retract', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1975 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1976 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1977 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1978 self.assertEqual(['item1', 'item2'], request.itemIdentifiers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1979
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1980
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1981 def test_fromElementPurge(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1982 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1983 Test parsing a purge request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1984 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1985
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1986 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1987 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1988 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1989 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1990 <purge node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1991 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1992 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1993 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1994
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1995 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1996 self.assertEqual('purge', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1997 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1998 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1999 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2000
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2001
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2002 def test_fromElementDelete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2003 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2004 Test parsing a delete request.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2005 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2006
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2007 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2008 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2009 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2010 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2011 <delete node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2012 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2013 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2014 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2015
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2016 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2017 self.assertEqual('delete', request.verb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2018 self.assertEqual(JID('user@example.org'), request.sender)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2019 self.assertEqual(JID('pubsub.example.org'), request.recipient)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2020 self.assertEqual('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2021
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2022
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2023
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2024 class PubSubServiceTest(unittest.TestCase, TestableRequestHandlerMixin):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2025 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2026 Tests for L{pubsub.PubSubService}.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2027 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2028
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2029 def setUp(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2030 self.stub = XmlStreamStub()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2031 self.resource = pubsub.PubSubResource()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2032 self.service = pubsub.PubSubService(self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2033 self.service.send = self.stub.xmlstream.send
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2034
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2035 def test_interface(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2036 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2037 Do instances of L{pubsub.PubSubService} provide L{iwokkel.IPubSubService}?
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2038 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2039 verify.verifyObject(iwokkel.IPubSubService, self.service)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2040
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2041
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2042 def test_interfaceIDisco(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2043 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2044 Do instances of L{pubsub.PubSubService} provide L{iwokkel.IDisco}?
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2045 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2046 verify.verifyObject(iwokkel.IDisco, self.service)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2047
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2048
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2049 def test_connectionMade(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2050 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2051 Verify setup of observers in L{pubsub.connectionMade}.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2052 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2053 requests = []
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2054
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2055 def handleRequest(iq):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2056 requests.append(iq)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2057
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2058 self.service.xmlstream = self.stub.xmlstream
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2059 self.service.handleRequest = handleRequest
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2060 self.service.connectionMade()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2061
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2062 for namespace in (NS_PUBSUB, NS_PUBSUB_OWNER):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2063 for stanzaType in ('get', 'set'):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2064 iq = domish.Element((None, 'iq'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2065 iq['type'] = stanzaType
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2066 iq.addElement((namespace, 'pubsub'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2067 self.stub.xmlstream.dispatch(iq)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2068
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2069 self.assertEqual(4, len(requests))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2070
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2071
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2072 def test_getDiscoInfo(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2073 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2074 Test getDiscoInfo calls getNodeInfo and returns some minimal info.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2075 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2076 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2077 discoInfo = disco.DiscoInfo()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2078 for item in info:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2079 discoInfo.append(item)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2080 self.assertIn(('pubsub', 'service'), discoInfo.identities)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2081 self.assertIn(disco.NS_DISCO_ITEMS, discoInfo.features)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2082
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2083 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2084 JID('pubsub.example.org'), '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2085 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2086 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2087
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2088
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2089 def test_getDiscoInfoNodeType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2090 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2091 Test getDiscoInfo with node type.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2092 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2093 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2094 discoInfo = disco.DiscoInfo()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2095 for item in info:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2096 discoInfo.append(item)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2097 self.assertIn(('pubsub', 'collection'), discoInfo.identities)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2098
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2099 def getInfo(requestor, target, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2100 return defer.succeed({'type': 'collection',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2101 'meta-data': {}})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2102
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2103 self.resource.getInfo = getInfo
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2104 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2105 JID('pubsub.example.org'), '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2106 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2107 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2108
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2109
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2110 def test_getDiscoInfoMetaData(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2111 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2112 Test getDiscoInfo with returned meta data.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2113 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2114 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2115 discoInfo = disco.DiscoInfo()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2116 for item in info:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2117 discoInfo.append(item)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2118
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2119 self.assertIn(('pubsub', 'leaf'), discoInfo.identities)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2120 self.assertIn(NS_PUBSUB_META_DATA, discoInfo.extensions)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2121 form = discoInfo.extensions[NS_PUBSUB_META_DATA]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2122 self.assertIn('pubsub#node_type', form.fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2123
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2124 def getInfo(requestor, target, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2125 metaData = [{'var': 'pubsub#persist_items',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2126 'label': 'Persist items to storage',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2127 'value': True}]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2128 return defer.succeed({'type': 'leaf', 'meta-data': metaData})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2129
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2130 self.resource.getInfo = getInfo
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2131 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2132 JID('pubsub.example.org'), '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2133 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2134 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2135
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2136
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2137 def test_getDiscoInfoResourceFeatures(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2138 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2139 Test getDiscoInfo with the resource features.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2140 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2141 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2142 discoInfo = disco.DiscoInfo()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2143 for item in info:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2144 discoInfo.append(item)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2145 self.assertIn('http://jabber.org/protocol/pubsub#publish',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2146 discoInfo.features)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2147
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2148 self.resource.features = ['publish']
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2149 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2150 JID('pubsub.example.org'), '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2151 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2152 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2153
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2154
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2155 def test_getDiscoInfoBadResponse(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2156 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2157 If getInfo returns invalid response, it should be logged, then ignored.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2158 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2159 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2160 self.assertEquals([], info)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2161 self.assertEqual(1, len(self.flushLoggedErrors(TypeError)))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2162
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2163 def getInfo(requestor, target, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2164 return defer.succeed('bad response')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2165
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2166 self.resource.getInfo = getInfo
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2167 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2168 JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2169 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2170 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2171
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2172
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2173 def test_getDiscoInfoException(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2174 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2175 If getInfo returns invalid response, it should be logged, then ignored.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2176 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2177 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2178 self.assertEquals([], info)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2179 self.assertEqual(1, len(self.flushLoggedErrors(NotImplementedError)))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2180
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2181 def getInfo(requestor, target, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2182 return defer.fail(NotImplementedError())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2183
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2184 self.resource.getInfo = getInfo
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2185 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2186 JID('pubsub.example.org'), 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2187 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2188 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2189
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2190
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2191 def test_getDiscoItemsRoot(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2192 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2193 Test getDiscoItems on the root node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2194 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2195 def getNodes(requestor, service, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2196 return defer.succeed(['node1', 'node2'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2197
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2198 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2199 self.assertEqual(2, len(items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2200 item1, item2 = items
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2201
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2202 self.assertEqual(JID('pubsub.example.org'), item1.entity)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2203 self.assertEqual('node1', item1.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2204
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2205 self.assertEqual(JID('pubsub.example.org'), item2.entity)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2206 self.assertEqual('node2', item2.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2207
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2208 self.resource.getNodes = getNodes
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2209 d = self.service.getDiscoItems(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2210 JID('pubsub.example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2211 '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2212 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2213 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2214
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2215
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2216 def test_getDiscoItemsRootHideNodes(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2217 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2218 Test getDiscoItems on the root node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2219 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2220 def getNodes(requestor, service, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2221 raise Exception("Unexpected call to getNodes")
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2222
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2223 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2224 self.assertEqual([], items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2225
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2226 self.service.hideNodes = True
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2227 self.resource.getNodes = getNodes
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2228 d = self.service.getDiscoItems(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2229 JID('pubsub.example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2230 '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2231 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2232 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2233
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2234
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2235 def test_getDiscoItemsNonRoot(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2236 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2237 Test getDiscoItems on a non-root node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2238 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2239 def getNodes(requestor, service, nodeIdentifier):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2240 return defer.succeed(['node1', 'node2'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2241
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2242 def cb(items):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2243 self.assertEqual(2, len(items))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2244
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2245 self.resource.getNodes = getNodes
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2246 d = self.service.getDiscoItems(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2247 JID('pubsub.example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2248 'test')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2249 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2250 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2251
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2252
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2253 def test_on_publish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2254 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2255 A publish request should result in L{PubSubService.publish} being
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2256 called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2257 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2258
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2259 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2260 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2261 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2262 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2263 <publish node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2264 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2265 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2266 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2267
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2268 def publish(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2269 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2270
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2271 self.resource.publish = publish
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2272 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2273 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2274
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2275
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2276 def test_on_subscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2277 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2278 A successful subscription should return the current subscription.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2279 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2280
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2281 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2282 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2283 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2284 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2285 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2286 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2287 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2288 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2289
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2290 def subscribe(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2291 return defer.succeed(pubsub.Subscription(request.nodeIdentifier,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2292 request.subscriber,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2293 'subscribed'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2294
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2295 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2296 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2297 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2298 subscription = element.subscription
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2299 self.assertEqual(NS_PUBSUB, subscription.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2300 self.assertEqual('test', subscription['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2301 self.assertEqual('user@example.org/Home', subscription['jid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2302 self.assertEqual('subscribed', subscription['subscription'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2303
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2304 self.resource.subscribe = subscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2305 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2306 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2307 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2308 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2309
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2310
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2311 def test_on_subscribeEmptyNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2312 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2313 A successful subscription on root node should return no node attribute.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2314 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2315
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2316 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2317 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2318 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2319 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2320 <subscribe jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2321 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2322 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2323 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2324
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2325 def subscribe(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2326 return defer.succeed(pubsub.Subscription(request.nodeIdentifier,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2327 request.subscriber,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2328 'subscribed'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2329
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2330 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2331 self.assertFalse(element.subscription.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2332
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2333 self.resource.subscribe = subscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2334 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2335 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2336 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2337 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2338
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2339
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2340 def test_on_subscribeSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2341 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2342 If a subscription returns a subid, this should be available.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2343 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2344
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2345 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2346 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2347 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2348 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2349 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2350 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2351 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2352 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2353
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2354 def subscribe(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2355 subscription = pubsub.Subscription(request.nodeIdentifier,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2356 request.subscriber,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2357 'subscribed',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2358 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2359 return defer.succeed(subscription)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2360
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2361 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2362 self.assertEqual('1234', element.subscription.getAttribute('subid'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2363
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2364 self.resource.subscribe = subscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2365 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2366 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2367 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2368 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2369
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2370
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2371 def test_on_unsubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2372 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2373 A successful unsubscription should return an empty response.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2374 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2375
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2376 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2377 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2378 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2379 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2380 <unsubscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2381 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2382 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2383 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2384
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2385 def unsubscribe(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2386 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2387
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2388 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2389 self.assertIdentical(None, element)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2390
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2391 self.resource.unsubscribe = unsubscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2392 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2393 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2394 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2395 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2396
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2397
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2398 def test_on_unsubscribeSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2399 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2400 A successful unsubscription with subid should return an empty response.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2401 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2402
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2403 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2404 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2405 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2406 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2407 <unsubscribe node='test' jid='user@example.org/Home' subid='1234'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2408 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2409 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2410 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2411
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2412 def unsubscribe(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2413 self.assertEqual('1234', request.subscriptionIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2414 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2415
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2416 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2417 self.assertIdentical(None, element)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2418
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2419 self.resource.unsubscribe = unsubscribe
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2420 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2421 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2422 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2423 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2424
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2425
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2426 def test_on_optionsGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2427 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2428 Getting subscription options is not supported.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2429 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2430
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2431 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2432 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2433 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2434 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2435 <options node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2436 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2437 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2438 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2439
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2440 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2441 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2442 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2443 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2444
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2445 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2446 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2447 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2448 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2449
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2450
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2451 def test_on_optionsSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2452 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2453 Setting subscription options is not supported.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2454 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2455
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2456 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2457 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2458 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2459 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2460 <options node='test' jid='user@example.org/Home'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2461 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2462 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2463 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2464 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2465 <field var='pubsub#deliver'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2466 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2467 </options>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2468 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2469 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2470 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2471
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2472 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2473 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2474 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2475 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2476
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2477 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2478 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2479 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2480 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2481
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2482
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2483 def test_on_subscriptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2484 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2485 A subscriptions request should result in
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2486 L{PubSubService.subscriptions} being called and the result prepared
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2487 for the response.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2488 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2489
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2490 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2491 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2492 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2493 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2494 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2495 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2496 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2497 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2498
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2499 def subscriptions(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2500 subscription = pubsub.Subscription('test', JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2501 'subscribed')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2502 return defer.succeed([subscription])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2503
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2504 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2505 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2506 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2507 self.assertEqual(NS_PUBSUB, element.subscriptions.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2508 children = list(element.subscriptions.elements())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2509 self.assertEqual(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2510 subscription = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2511 self.assertEqual('subscription', subscription.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2512 self.assertEqual(NS_PUBSUB, subscription.uri, NS_PUBSUB)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2513 self.assertEqual('user@example.org', subscription['jid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2514 self.assertEqual('test', subscription['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2515 self.assertEqual('subscribed', subscription['subscription'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2516
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2517 self.resource.subscriptions = subscriptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2518 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2519 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2520 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2521 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2522
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2523
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2524 def test_on_subscriptionsWithSubscriptionIdentifier(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2525 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2526 A subscriptions request response should include subids, if set.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2527 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2528
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2529 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2530 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2531 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2532 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2533 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2534 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2535 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2536 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2537
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2538 def subscriptions(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2539 subscription = pubsub.Subscription('test', JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2540 'subscribed',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2541 subscriptionIdentifier='1234')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2542 return defer.succeed([subscription])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2543
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2544 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2545 subscription = element.subscriptions.subscription
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2546 self.assertEqual('1234', subscription['subid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2547
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2548 self.resource.subscriptions = subscriptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2549 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2550 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2551 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2552 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2553
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2554
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2555 def test_on_affiliations(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2556 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2557 A subscriptions request should result in
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2558 L{PubSubService.affiliations} being called and the result prepared
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2559 for the response.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2560 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2561
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2562 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2563 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2564 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2565 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2566 <affiliations/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2567 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2568 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2569 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2570
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2571 def affiliations(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2572 affiliation = ('test', 'owner')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2573 return defer.succeed([affiliation])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2574
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2575 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2576 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2577 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2578 self.assertEqual(NS_PUBSUB, element.affiliations.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2579 children = list(element.affiliations.elements())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2580 self.assertEqual(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2581 affiliation = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2582 self.assertEqual('affiliation', affiliation.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2583 self.assertEqual(NS_PUBSUB, affiliation.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2584 self.assertEqual('test', affiliation['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2585 self.assertEqual('owner', affiliation['affiliation'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2586
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2587 self.resource.affiliations = affiliations
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2588 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2589 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2590 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2591 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2592
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2593
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2594 def test_on_create(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2595 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2596 Replies to create node requests don't return the created node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2597 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2598
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2599 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2600 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2601 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2602 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2603 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2604 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2605 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2606 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2607
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2608 def create(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2609 return defer.succeed(request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2610
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2611 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2612 self.assertIdentical(None, element)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2613
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2614 self.resource.create = create
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2615 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2616 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2617 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2618 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2619
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2620
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2621 def test_on_createChanged(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2622 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2623 Replies to create node requests return the created node if changed.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2624 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2625
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2626 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2627 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2628 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2629 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2630 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2631 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2632 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2633 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2634
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2635 def create(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2636 return defer.succeed(u'myrenamednode')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2637
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2638 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2639 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2640 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2641 self.assertEqual(NS_PUBSUB, element.create.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2642 self.assertEqual(u'myrenamednode',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2643 element.create.getAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2644
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2645 self.resource.create = create
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2646 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2647 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2648 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2649 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2650
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2651
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2652 def test_on_createInstant(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2653 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2654 Replies to create instant node requests return the created node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2655 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2656
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2657 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2658 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2659 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2660 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2661 <create/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2662 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2663 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2664 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2665
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2666 def create(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2667 return defer.succeed(u'random')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2668
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2669 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2670 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2671 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2672 self.assertEqual(NS_PUBSUB, element.create.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2673 self.assertEqual(u'random', element.create.getAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2674
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2675 self.resource.create = create
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2676 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2677 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2678 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2679 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2680
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2681
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2682 def test_on_createWithConfig(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2683 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2684 On a node create with configuration request the Data Form is parsed and
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2685 L{PubSubResource.create} is called with the passed options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2686 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2687
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2688 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2689 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2690 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2691 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2692 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2693 <configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2694 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2695 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2696 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2697 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2698 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2699 <field var='pubsub#persist_items'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2700 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2701 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2702 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2703 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2704 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2705
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2706 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2707 return {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2708 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2709 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2710 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2711 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2712 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2713 "label": "Deliver payloads with event notifications"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2714 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2715
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2716 def create(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2717 self.assertEqual({'pubsub#deliver_payloads': False,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2718 'pubsub#persist_items': True},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2719 request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2720 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2721
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2722 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2723 self.resource.create = create
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2724 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2725 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2726
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2727
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2728 def test_on_default(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2729 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2730 A default request returns default options filtered by available fields.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2731 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2732
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2733 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2734 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2735 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2736 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2737 <default/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2738 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2739 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2740 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2741 fieldDefs = {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2742 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2743 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2744 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2745 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2746 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2747 "label": "Deliver payloads with event notifications"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2748 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2749
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2750 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2751 return fieldDefs
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2752
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2753 def default(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2754 return defer.succeed({'pubsub#persist_items': 'false',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2755 'x-myfield': '1'})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2756
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2757 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2758 self.assertEquals('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2759 self.assertEquals(NS_PUBSUB_OWNER, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2760 self.assertEquals(NS_PUBSUB_OWNER, element.default.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2761 form = data_form.Form.fromElement(element.default.x)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2762 self.assertEquals(NS_PUBSUB_NODE_CONFIG, form.formNamespace)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2763 form.typeCheck(fieldDefs)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2764 self.assertIn('pubsub#persist_items', form.fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2765 self.assertFalse(form.fields['pubsub#persist_items'].value)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2766 self.assertNotIn('x-myfield', form.fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2767
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2768 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2769 self.resource.default = default
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2770 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2771 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2772 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2773 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2774
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2775
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2776 def test_on_defaultUnknownNodeType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2777 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2778 Unknown node types yield non-acceptable.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2779
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2780 Both C{getConfigurationOptions} and C{default} must not be called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2781 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2782
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2783 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2784 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2785 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2786 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2787 <default>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2788 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2789 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2790 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2791 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2792 <field var='pubsub#node_type'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2793 <value>unknown</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2794 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2795 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2796 </default>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2797
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2798 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2799 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2800 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2801
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2802 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2803 self.fail("Unexpected call to getConfigurationOptions")
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2804
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2805 def default(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2806 self.fail("Unexpected call to default")
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2807
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2808 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2809 self.assertEquals('not-acceptable', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2810
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2811 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2812 self.resource.default = default
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2813 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2814 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2815 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2816 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2817 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2818
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2819
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2820 def test_on_configureGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2821 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2822 On a node configuration get
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2823 requestL{PubSubResource.configureGet} is called and results in a
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2824 data form with the configuration.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2825 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2826
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2827 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2828 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2829 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2830 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2831 <configure node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2832 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2833 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2834 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2835
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2836 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2837 return {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2838 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2839 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2840 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2841 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2842 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2843 "label": "Deliver payloads with event notifications"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2844 "pubsub#owner":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2845 {"type": "jid-single",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2846 "label": "Owner of the node"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2847 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2848
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2849 def configureGet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2850 return defer.succeed({'pubsub#deliver_payloads': '0',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2851 'pubsub#persist_items': '1',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2852 'pubsub#owner': JID('user@example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2853 'x-myfield': 'a'})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2854
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2855 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2856 self.assertEqual('pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2857 self.assertEqual(NS_PUBSUB_OWNER, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2858 self.assertEqual(NS_PUBSUB_OWNER, element.configure.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2859 form = data_form.Form.fromElement(element.configure.x)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2860 self.assertEqual(NS_PUBSUB_NODE_CONFIG, form.formNamespace)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2861 fields = form.fields
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2862
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2863 self.assertIn('pubsub#deliver_payloads', fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2864 field = fields['pubsub#deliver_payloads']
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2865 self.assertEqual('boolean', field.fieldType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2866 field.typeCheck()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2867 self.assertEqual(False, field.value)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2868
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2869 self.assertIn('pubsub#persist_items', fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2870 field = fields['pubsub#persist_items']
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2871 self.assertEqual('boolean', field.fieldType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2872 field.typeCheck()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2873 self.assertEqual(True, field.value)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2874
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2875 self.assertIn('pubsub#owner', fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2876 field = fields['pubsub#owner']
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2877 self.assertEqual('jid-single', field.fieldType)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2878 field.typeCheck()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2879 self.assertEqual(JID('user@example.org'), field.value)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2880
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2881 self.assertNotIn('x-myfield', fields)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2882
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2883 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2884 self.resource.configureGet = configureGet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2885 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2886 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2887 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2888 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2889
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2890
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2891 def test_on_configureSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2892 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2893 On a node configuration set request the Data Form is parsed and
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2894 L{PubSubResource.configureSet} is called with the passed options.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2895 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2896
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2897 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2898 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2899 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2900 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2901 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2902 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2903 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2904 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2905 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2906 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2907 <field var='pubsub#persist_items'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2908 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2909 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2910 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2911 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2912 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2913
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2914 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2915 return {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2916 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2917 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2918 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2919 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2920 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2921 "label": "Deliver payloads with event notifications"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2922 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2923
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2924 def configureSet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2925 self.assertEqual({'pubsub#deliver_payloads': False,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2926 'pubsub#persist_items': True},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2927 request.options.getValues())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2928 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2929
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2930 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2931 self.resource.configureSet = configureSet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2932 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2933 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2934
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2935
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2936 def test_on_configureSetCancel(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2937 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2938 The node configuration is cancelled,
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2939 L{PubSubResource.configureSet} not called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2940 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2941
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2942 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2943 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2944 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2945 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2946 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2947 <x xmlns='jabber:x:data' type='cancel'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2948 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2949 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2950 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2951 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2952 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2953 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2954 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2955 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2956
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2957 def configureSet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2958 self.fail("Unexpected call to setConfiguration")
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2959
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2960 self.resource.configureSet = configureSet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2961 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2962 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2963
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2964
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2965 def test_on_configureSetIgnoreUnknown(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2966 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2967 On a node configuration set request unknown fields should be ignored.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2968 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2969
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2970 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2971 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2972 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2973 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2974 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2975 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2976 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2977 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2978 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2979 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2980 <field var='x-myfield'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2981 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2982 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2983 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2984 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2985 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2986
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2987 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2988 return {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2989 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2990 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2991 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2992 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2993 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2994 "label": "Deliver payloads with event notifications"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2995 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2996
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2997 def configureSet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2998 self.assertEquals(['pubsub#deliver_payloads'],
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2999 request.options.keys())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3000
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3001 self.resource.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3002 self.resource.configureSet = configureSet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3003 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3004 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3005
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3006
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3007 def test_on_configureSetBadFormType(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3008 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3009 On a node configuration set request unknown fields should be ignored.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3010 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3011
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3012 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3013 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3014 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3015 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3016 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3017 <x xmlns='jabber:x:data' type='result'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3018 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3019 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3020 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3021 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3022 <field var='x-myfield'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3023 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3024 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3025 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3026 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3027 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3028
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3029 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3030 self.assertEquals('bad-request', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3031 self.assertEqual("Unexpected form type 'result'", result.text)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3032
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3033 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3034 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3035 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3036 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3037
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3038
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3039 def test_on_items(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3040 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3041 On a items request, return all items for the given node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3042 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3043 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3044 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3045 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3046 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3047 <items node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3048 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3049 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3050 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3051
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3052 def items(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3053 return defer.succeed([pubsub.Item('current')])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3054
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3055 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3056 self.assertEqual(NS_PUBSUB, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3057 self.assertEqual(NS_PUBSUB, element.items.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3058 self.assertEqual(1, len(element.items.children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3059 item = element.items.children[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3060 self.assertTrue(domish.IElement.providedBy(item))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3061 self.assertEqual('item', item.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3062 self.assertEqual(NS_PUBSUB, item.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3063 self.assertEqual('current', item['id'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3064
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3065 self.resource.items = items
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3066 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3067 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3068 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3069 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3070
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3071
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3072 def test_on_retract(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3073 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3074 A retract request should result in L{PubSubResource.retract}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3075 being called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3076 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3077
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3078 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3079 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3080 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3081 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3082 <retract node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3083 <item id='item1'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3084 <item id='item2'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3085 </retract>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3086 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3087 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3088 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3089
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3090 def retract(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3091 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3092
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3093 self.resource.retract = retract
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3094 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3095 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3096
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3097
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3098 def test_on_purge(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3099 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3100 A purge request should result in L{PubSubResource.purge} being
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3101 called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3102 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3103
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3104 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3105 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3106 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3107 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3108 <purge node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3109 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3110 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3111 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3112
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3113 def purge(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3114 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3115
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3116 self.resource.purge = purge
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3117 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3118 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3119
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3120
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3121 def test_on_delete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3122 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3123 A delete request should result in L{PubSubResource.delete} being
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3124 called.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3125 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3126
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3127 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3128 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3129 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3130 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3131 <delete node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3132 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3133 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3134 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3135
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3136 def delete(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3137 return defer.succeed(None)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3138
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3139 self.resource.delete = delete
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3140 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3141 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3142
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3143
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3144 def test_notifyPublish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3145 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3146 Publish notifications are sent to the subscribers.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3147 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3148 subscriber = JID('user@example.org')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3149 subscriptions = [pubsub.Subscription('test', subscriber, 'subscribed')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3150 items = [pubsub.Item('current')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3151 notifications = [(subscriber, subscriptions, items)]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3152 self.service.notifyPublish(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3153 notifications)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3154 message = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3155
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3156 self.assertEquals('message', message.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3157 self.assertIdentical(None, message.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3158 self.assertEquals('user@example.org', message['to'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3159 self.assertEquals('pubsub.example.org', message['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3160 self.assertTrue(message.event)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3161 self.assertEquals(NS_PUBSUB_EVENT, message.event.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3162 self.assertTrue(message.event.items)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3163 self.assertEquals(NS_PUBSUB_EVENT, message.event.items.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3164 self.assertTrue(message.event.items.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3165 self.assertEquals('test', message.event.items['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3166 itemElements = list(domish.generateElementsQNamed(
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3167 message.event.items.children, 'item', NS_PUBSUB_EVENT))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3168 self.assertEquals(1, len(itemElements))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3169 self.assertEquals('current', itemElements[0].getAttribute('id'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3170
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3171
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3172 def test_notifyPublishCollection(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3173 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3174 Publish notifications are sent to the subscribers of collections.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3175
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3176 The node the item was published to is on the C{items} element, while
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3177 the subscribed-to node is in the C{'Collections'} SHIM header.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3178 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3179 subscriber = JID('user@example.org')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3180 subscriptions = [pubsub.Subscription('', subscriber, 'subscribed')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3181 items = [pubsub.Item('current')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3182 notifications = [(subscriber, subscriptions, items)]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3183 self.service.notifyPublish(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3184 notifications)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3185 message = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3186
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3187 self.assertTrue(message.event.items.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3188 self.assertEquals('test', message.event.items['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3189 headers = shim.extractHeaders(message)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3190 self.assertIn('Collection', headers)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3191 self.assertIn('', headers['Collection'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3192
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3193
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3194 def test_notifyDelete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3195 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3196 Subscribers should be sent a delete notification.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3197 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3198 subscriptions = [JID('user@example.org')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3199 self.service.notifyDelete(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3200 subscriptions)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3201 message = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3202
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3203 self.assertEquals('message', message.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3204 self.assertIdentical(None, message.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3205 self.assertEquals('user@example.org', message['to'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3206 self.assertEquals('pubsub.example.org', message['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3207 self.assertTrue(message.event)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3208 self.assertEqual(NS_PUBSUB_EVENT, message.event.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3209 self.assertTrue(message.event.delete)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3210 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3211 self.assertTrue(message.event.delete.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3212 self.assertEqual('test', message.event.delete['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3213
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3214
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3215 def test_notifyDeleteRedirect(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3216 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3217 Subscribers should be sent a delete notification with redirect.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3218 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3219 redirectURI = 'xmpp:pubsub.example.org?;node=test2'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3220 subscriptions = [JID('user@example.org')]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3221 self.service.notifyDelete(JID('pubsub.example.org'), 'test',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3222 subscriptions, redirectURI)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3223 message = self.stub.output[-1]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3224
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3225 self.assertEquals('message', message.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3226 self.assertIdentical(None, message.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3227 self.assertEquals('user@example.org', message['to'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3228 self.assertEquals('pubsub.example.org', message['from'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3229 self.assertTrue(message.event)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3230 self.assertEqual(NS_PUBSUB_EVENT, message.event.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3231 self.assertTrue(message.event.delete)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3232 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3233 self.assertTrue(message.event.delete.hasAttribute('node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3234 self.assertEqual('test', message.event.delete['node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3235 self.assertTrue(message.event.delete.redirect)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3236 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.redirect.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3237 self.assertTrue(message.event.delete.redirect.hasAttribute('uri'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3238 self.assertEqual(redirectURI, message.event.delete.redirect['uri'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3239
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3240
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3241 def test_on_subscriptionsGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3242 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3243 Getting subscription options is not supported.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3244 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3245
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3246 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3247 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3248 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3249 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3250 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3251 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3252 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3253 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3254
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3255 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3256 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3257 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3258 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3259 self.assertEquals('manage-subscriptions',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3260 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3261
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3262 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3263 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3264 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3265 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3266
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3267
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3268 def test_on_subscriptionsSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3269 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3270 Setting subscription options is not supported.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3271 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3272
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3273 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3274 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3275 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3276 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3277 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3278 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3279 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3280 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3281
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3282 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3283 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3284 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3285 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3286 self.assertEquals('manage-subscriptions',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3287 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3288
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3289 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3290 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3291 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3292 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3293
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3294
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3295 def test_on_affiliationsGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3296 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3297 Getting node affiliations should have.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3298 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3299
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3300 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3301 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3302 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3303 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3304 <affiliations node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3305 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3306 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3307 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3308
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3309 def affiliationsGet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3310 self.assertEquals('test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3311 return defer.succeed({JID('user@example.org'): 'owner'})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3312
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3313 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3314 self.assertEquals(u'pubsub', element.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3315 self.assertEquals(NS_PUBSUB_OWNER, element.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3316 self.assertEquals(NS_PUBSUB_OWNER, element.affiliations.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3317 self.assertEquals(u'test', element.affiliations[u'node'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3318 children = list(element.affiliations.elements())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3319 self.assertEquals(1, len(children))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3320 affiliation = children[0]
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3321 self.assertEquals(u'affiliation', affiliation.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3322 self.assertEquals(NS_PUBSUB_OWNER, affiliation.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3323 self.assertEquals(u'user@example.org', affiliation[u'jid'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3324 self.assertEquals(u'owner', affiliation[u'affiliation'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3325
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3326 self.resource.affiliationsGet = affiliationsGet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3327 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3328 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3329 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3330 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3331
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3332
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3333 def test_on_affiliationsGetEmptyNode(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3334 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3335 Getting node affiliations without node should assume empty node.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3336 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3337
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3338 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3339 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3340 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3341 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3342 <affiliations/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3343 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3344 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3345 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3346
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3347 def affiliationsGet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3348 self.assertEqual('', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3349 return defer.succeed({})
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3350
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3351 def cb(element):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3352 self.assertFalse(element.affiliations.hasAttribute(u'node'))
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3353
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3354 self.resource.affiliationsGet = affiliationsGet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3355 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3356 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3357 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3358 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3359
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3360
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3361 def test_on_affiliationsSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3362 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3363 Setting node affiliations has the affiliations to be modified.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3364 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3365
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3366 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3367 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3368 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3369 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3370 <affiliations node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3371 <affiliation jid='other@example.org' affiliation='publisher'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3372 </affiliations>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3373 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3374 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3375 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3376
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3377 def affiliationsSet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3378 self.assertEquals(u'test', request.nodeIdentifier)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3379 otherJID = JID(u'other@example.org')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3380 self.assertIn(otherJID, request.affiliations)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3381 self.assertEquals(u'publisher', request.affiliations[otherJID])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3382
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3383 self.resource.affiliationsSet = affiliationsSet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3384 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3385
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3386
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3387 def test_on_affiliationsSetBareJID(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3388 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3389 Affiliations are always on the bare JID.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3390 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3391
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3392 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3393 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3394 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3395 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3396 <affiliations node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3397 <affiliation jid='other@example.org/Home'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3398 affiliation='publisher'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3399 </affiliations>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3400 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3401 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3402 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3403
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3404 def affiliationsSet(request):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3405 otherJID = JID(u'other@example.org')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3406 self.assertIn(otherJID, request.affiliations)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3407
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3408 self.resource.affiliationsSet = affiliationsSet
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3409 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3410
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3411
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3412 def test_on_affiliationsSetMultipleForSameEntity(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3413 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3414 Setting node affiliations can only have one item per entity.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3415 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3416
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3417 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3418 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3419 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3420 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3421 <affiliations node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3422 <affiliation jid='other@example.org' affiliation='publisher'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3423 <affiliation jid='other@example.org' affiliation='owner'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3424 </affiliations>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3425 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3426 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3427 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3428
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3429 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3430 self.assertEquals('bad-request', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3431
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3432 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3433 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3434 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3435 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3436
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3437
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3438 def test_on_affiliationsSetMissingJID(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3439 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3440 Setting node affiliations must include a JID per affiliation.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3441 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3442
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3443 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3444 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3445 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3446 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3447 <affiliations node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3448 <affiliation affiliation='publisher'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3449 </affiliations>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3450 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3451 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3452 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3453
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3454 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3455 self.assertEquals('bad-request', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3456
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3457 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3458 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3459 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3460 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3461
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3462
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3463 def test_on_affiliationsSetMissingAffiliation(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3464 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3465 Setting node affiliations must include an affiliation.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3466 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3467
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3468 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3469 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3470 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3471 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3472 <affiliations node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3473 <affiliation jid='other@example.org'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3474 </affiliations>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3475 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3476 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3477 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3478
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3479 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3480 self.assertEquals('bad-request', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3481
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3482 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3483 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3484 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3485 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3486
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3487
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3488
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3489 class PubSubServiceWithoutResourceTest(unittest.TestCase, TestableRequestHandlerMixin):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3490
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3491 def setUp(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3492 self.stub = XmlStreamStub()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3493 self.service = pubsub.PubSubService()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3494 self.service.send = self.stub.xmlstream.send
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3495
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3496
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3497 def test_getDiscoInfo(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3498 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3499 Test getDiscoInfo calls getNodeInfo and returns some minimal info.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3500 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3501 def cb(info):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3502 discoInfo = disco.DiscoInfo()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3503 for item in info:
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3504 discoInfo.append(item)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3505 self.assertIn(('pubsub', 'service'), discoInfo.identities)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3506 self.assertIn(disco.NS_DISCO_ITEMS, discoInfo.features)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3507
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3508 d = self.service.getDiscoInfo(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3509 JID('pubsub.example.org'), '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3510 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3511 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3512
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3513
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3514 def test_publish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3515 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3516 Non-overridden L{PubSubService.publish} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3517 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3518
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3519 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3520 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3521 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3522 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3523 <publish node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3524 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3525 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3526 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3527
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3528 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3529 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3530 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3531 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3532 self.assertEquals('publish', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3533
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3534 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3535 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3536 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3537 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3538
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3539
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3540 def test_subscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3541 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3542 Non-overridden L{PubSubService.subscribe} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3543 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3544
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3545 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3546 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3547 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3548 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3549 <subscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3550 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3551 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3552 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3553
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3554 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3555 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3556 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3557 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3558 self.assertEquals('subscribe', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3559
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3560 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3561 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3562 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3563 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3564
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3565
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3566 def test_unsubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3567 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3568 Non-overridden L{PubSubService.unsubscribe} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3569 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3570
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3571 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3572 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3573 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3574 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3575 <unsubscribe node='test' jid='user@example.org/Home'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3576 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3577 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3578 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3579
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3580 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3581 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3582 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3583 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3584 self.assertEquals('subscribe', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3585
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3586 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3587 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3588 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3589 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3590
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3591
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3592 def test_subscriptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3593 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3594 Non-overridden L{PubSubService.subscriptions} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3595 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3596
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3597 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3598 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3599 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3600 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3601 <subscriptions/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3602 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3603 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3604 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3605
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3606 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3607 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3608 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3609 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3610 self.assertEquals('retrieve-subscriptions',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3611 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3612
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3613 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3614 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3615 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3616 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3617
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3618
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3619 def test_affiliations(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3620 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3621 Non-overridden L{PubSubService.affiliations} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3622 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3623
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3624 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3625 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3626 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3627 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3628 <affiliations/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3629 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3630 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3631 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3632
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3633 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3634 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3635 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3636 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3637 self.assertEquals('retrieve-affiliations',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3638 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3639
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3640 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3641 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3642 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3643 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3644
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3645
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3646 def test_create(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3647 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3648 Non-overridden L{PubSubService.create} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3649 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3650
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3651 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3652 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3653 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3654 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3655 <create node='mynode'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3656 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3657 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3658 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3659
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3660 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3661 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3662 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3663 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3664 self.assertEquals('create-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3665
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3666 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3667 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3668 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3669 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3670
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3671
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3672 def test_getDefaultConfiguration(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3673 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3674 Non-overridden L{PubSubService.getDefaultConfiguration} yields
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3675 unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3676 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3677
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3678 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3679 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3680 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3681 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3682 <default/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3683 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3684 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3685 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3686
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3687 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3688 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3689 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3690 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3691 self.assertEquals('retrieve-default', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3692
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3693 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3694 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3695 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3696 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3697
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3698
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3699 def test_getConfiguration(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3700 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3701 Non-overridden L{PubSubService.getConfiguration} yields unsupported
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3702 error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3703 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3704
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3705 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3706 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3707 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3708 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3709 <configure/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3710 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3711 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3712 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3713
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3714 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3715 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3716 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3717 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3718 self.assertEquals('config-node', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3719
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3720 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3721 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3722 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3723 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3724
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3725
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3726 def test_setConfiguration(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3727 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3728 Non-overridden L{PubSubService.setConfiguration} yields unsupported
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3729 error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3730 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3731
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3732 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3733 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3734 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3735 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3736 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3737 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3738 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3739 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3740 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3741 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3742 <field var='pubsub#persist_items'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3743 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3744 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3745 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3746 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3747 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3748
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3749 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3750 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3751 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3752 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3753 self.assertEquals('config-node', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3754
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3755 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3756 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3757 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3758 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3759
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3760
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3761 def test_setConfigurationOptionsDict(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3762 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3763 Options should be passed as a dictionary, not a form.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3764 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3765
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3766 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3767 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3768 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3769 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3770 <configure node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3771 <x xmlns='jabber:x:data' type='submit'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3772 <field var='FORM_TYPE' type='hidden'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3773 <value>http://jabber.org/protocol/pubsub#node_config</value>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3774 </field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3775 <field var='pubsub#deliver_payloads'><value>0</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3776 <field var='pubsub#persist_items'><value>1</value></field>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3777 </x>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3778 </configure>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3779 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3780 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3781 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3782
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3783 def getConfigurationOptions():
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3784 return {
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3785 "pubsub#persist_items":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3786 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3787 "label": "Persist items to storage"},
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3788 "pubsub#deliver_payloads":
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3789 {"type": "boolean",
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3790 "label": "Deliver payloads with event notifications"}
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3791 }
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3792
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3793 def setConfiguration(requestor, service, nodeIdentifier, options):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3794 self.assertIn('pubsub#deliver_payloads', options)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3795 self.assertFalse(options['pubsub#deliver_payloads'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3796 self.assertIn('pubsub#persist_items', options)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3797 self.assertTrue(options['pubsub#persist_items'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3798
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3799 self.service.getConfigurationOptions = getConfigurationOptions
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3800 self.service.setConfiguration = setConfiguration
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3801 return self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3802
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3803
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3804 def test_items(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3805 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3806 Non-overridden L{PubSubService.items} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3807 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3808 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3809 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3810 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3811 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3812 <items node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3813 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3814 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3815 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3816
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3817 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3818 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3819 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3820 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3821 self.assertEquals('retrieve-items', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3822
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3823 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3824 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3825 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3826 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3827
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3828
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3829 def test_retract(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3830 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3831 Non-overridden L{PubSubService.retract} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3832 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3833 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3834 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3835 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3836 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3837 <retract node='test'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3838 <item id='item1'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3839 <item id='item2'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3840 </retract>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3841 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3842 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3843 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3844
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3845 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3846 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3847 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3848 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3849 self.assertEquals('retract-items', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3850
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3851 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3852 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3853 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3854 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3855
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3856
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3857 def test_purge(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3858 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3859 Non-overridden L{PubSubService.purge} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3860 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3861 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3862 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3863 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3864 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3865 <purge node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3866 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3867 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3868 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3869
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3870 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3871 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3872 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3873 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3874 self.assertEquals('purge-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3875
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3876 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3877 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3878 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3879 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3880
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3881
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3882 def test_delete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3883 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3884 Non-overridden L{PubSubService.delete} yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3885 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3886 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3887 <iq type='set' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3888 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3889 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3890 <delete node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3891 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3892 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3893 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3894
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3895 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3896 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3897 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3898 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3899 self.assertEquals('delete-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3900
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3901 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3902 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3903 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3904 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3905
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3906
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3907 def test_unknown(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3908 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3909 Unknown verb yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3910 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3911 xml = """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3912 <iq type='get' to='pubsub.example.org'
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3913 from='user@example.org'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3914 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3915 <affiliations node='test'/>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3916 </pubsub>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3917 </iq>
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3918 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3919
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3920 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3921 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3922 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3923 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3924
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3925 d = self.handleRequest(xml)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3926 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3927 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3928 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3929
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3930
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3931
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3932 class PubSubResourceTest(unittest.TestCase):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3933
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3934 def setUp(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3935 self.resource = pubsub.PubSubResource()
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3936
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3937
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3938 def test_interface(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3939 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3940 Do instances of L{pubsub.PubSubResource} provide L{iwokkel.IPubSubResource}?
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3941 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3942 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3943
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3944
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3945 def test_getNodes(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3946 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3947 Default getNodes returns an empty list.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3948 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3949 def cb(nodes):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3950 self.assertEquals([], nodes)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3951
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3952 d = self.resource.getNodes(JID('user@example.org/home'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3953 JID('pubsub.example.org'),
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3954 '')
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3955 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3956 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3957
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3958
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3959 def test_publish(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3960 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3961 Non-overridden L{PubSubResource.publish} yields unsupported
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3962 error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3963 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3964
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3965 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3966 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3967 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3968 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3969 self.assertEquals('publish', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3970
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3971 d = self.resource.publish(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3972 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3973 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3974 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3975
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3976
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3977 def test_subscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3978 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3979 Non-overridden subscriptions yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3980 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3981
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3982 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3983 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3984 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3985 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3986 self.assertEquals('subscribe', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3987
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3988 d = self.resource.subscribe(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3989 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3990 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3991 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3992
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3993
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3994 def test_unsubscribe(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3995 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3996 Non-overridden unsubscribe yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3997 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3998
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3999 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4000 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4001 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4002 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4003 self.assertEquals('subscribe', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4004
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4005 d = self.resource.unsubscribe(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4006 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4007 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4008 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4009
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4010
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4011 def test_subscriptions(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4012 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4013 Non-overridden subscriptions yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4014 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4015
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4016 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4017 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4018 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4019 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4020 self.assertEquals('retrieve-subscriptions',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4021 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4022
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4023 d = self.resource.subscriptions(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4024 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4025 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4026 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4027
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4028
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4029 def test_affiliations(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4030 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4031 Non-overridden affiliations yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4032 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4033
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4034 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4035 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4036 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4037 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4038 self.assertEquals('retrieve-affiliations',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4039 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4040
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4041 d = self.resource.affiliations(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4042 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4043 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4044 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4045
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4046
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4047 def test_create(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4048 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4049 Non-overridden create yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4050 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4051
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4052 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4053 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4054 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4055 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4056 self.assertEquals('create-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4057
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4058 d = self.resource.create(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4059 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4060 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4061 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4062
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4063
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4064 def test_default(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4065 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4066 Non-overridden default yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4067 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4068
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4069 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4070 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4071 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4072 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4073 self.assertEquals('retrieve-default',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4074 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4075
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4076 d = self.resource.default(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4077 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4078 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4079 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4080
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4081
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4082 def test_configureGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4083 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4084 Non-overridden configureGet yields unsupported
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4085 error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4086 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4087
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4088 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4089 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4090 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4091 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4092 self.assertEquals('config-node', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4093
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4094 d = self.resource.configureGet(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4095 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4096 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4097 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4098
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4099
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4100 def test_configureSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4101 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4102 Non-overridden configureSet yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4103 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4104
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4105 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4106 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4107 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4108 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4109 self.assertEquals('config-node', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4110
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4111 d = self.resource.configureSet(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4112 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4113 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4114 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4115
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4116
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4117 def test_items(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4118 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4119 Non-overridden items yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4120 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4121
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4122 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4123 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4124 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4125 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4126 self.assertEquals('retrieve-items', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4127
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4128 d = self.resource.items(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4129 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4130 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4131 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4132
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4133
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4134 def test_retract(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4135 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4136 Non-overridden retract yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4137 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4138
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4139 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4140 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4141 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4142 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4143 self.assertEquals('retract-items', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4144
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4145 d = self.resource.retract(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4146 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4147 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4148 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4149
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4150
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4151 def test_purge(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4152 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4153 Non-overridden purge yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4154 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4155
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4156 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4157 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4158 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4159 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4160 self.assertEquals('purge-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4161
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4162 d = self.resource.purge(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4163 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4164 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4165 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4166
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4167
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4168 def test_delete(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4169 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4170 Non-overridden delete yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4171 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4172
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4173 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4174 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4175 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4176 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4177 self.assertEquals('delete-nodes', result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4178
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4179 d = self.resource.delete(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4180 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4181 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4182 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4183
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4184
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4185 def test_affiliationsGet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4186 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4187 Non-overridden owner affiliations get yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4188 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4189
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4190 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4191 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4192 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4193 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4194 self.assertEquals('modify-affiliations',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4195 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4196
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4197 d = self.resource.affiliationsGet(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4198 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4199 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4200 return d
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4201
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4202
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4203 def test_affiliationsSet(self):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4204 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4205 Non-overridden owner affiliations set yields unsupported error.
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4206 """
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4207
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4208 def cb(result):
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4209 self.assertEquals('feature-not-implemented', result.condition)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4210 self.assertEquals('unsupported', result.appCondition.name)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4211 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4212 self.assertEquals('modify-affiliations',
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4213 result.appCondition['feature'])
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4214
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4215 d = self.resource.affiliationsSet(pubsub.PubSubRequest())
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4216 self.assertFailure(d, error.StanzaError)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4217 d.addCallback(cb)
0fb5785b4c63 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4218 return d