annotate wokkel/test/test_pubsub.py @ 34:213122b92b08 0.6.1 0.6.1.1 0.7-dev cagou refacoring_messages

tmp/wokkel (rsm): fixes elements count (items retrieval with RSM max = 0)
author souliane <souliane@mailoo.org>
date Fri, 18 Mar 2016 09:14:00 +0100
parents 2cd4f0ab9ad1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1 # Copyright (c) Ralph Meijer.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # See LICENSE for details.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
5 Tests for L{wokkel.pubsub}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
6 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
7
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
8 from zope.interface import verify
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
9
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
10 from twisted.trial import unittest
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
11 from twisted.internet import defer
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
12 from twisted.words.xish import domish
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
13 from twisted.words.protocols.jabber import error
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
14 from twisted.words.protocols.jabber.jid import JID
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
15 from twisted.words.protocols.jabber.xmlstream import toResponse
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
16
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
17 from wokkel import data_form, disco, iwokkel, shim
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
18 from wokkel.generic import parseXml
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
19 from wokkel.test.helpers import TestableRequestHandlerMixin, XmlStreamStub
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
20
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
21 from sat.tmp.wokkel import pubsub
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
22
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
23 NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
2cd4f0ab9ad1 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'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
25 NS_PUBSUB_ERRORS = 'http://jabber.org/protocol/pubsub#errors'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
26 NS_PUBSUB_EVENT = 'http://jabber.org/protocol/pubsub#event'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
27 NS_PUBSUB_OWNER = 'http://jabber.org/protocol/pubsub#owner'
2cd4f0ab9ad1 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'
2cd4f0ab9ad1 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'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
30
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
31 def calledAsync(fn):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
32 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
34 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
35 d = defer.Deferred()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
36
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
37 def func(*args, **kwargs):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
38 try:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
39 result = fn(*args, **kwargs)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
40 except:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
41 d.errback()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
42 else:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
43 d.callback(result)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
44
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
45 return d, func
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
46
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
47
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
48 class SubscriptionTest(unittest.TestCase):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
49 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
50 Tests for L{pubsub.Subscription}.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
51 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
52
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
53 def test_fromElement(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
54 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
55 fromElement parses a subscription from XML DOM.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
56 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
57 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
58 <subscription node='test' jid='user@example.org/Home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
59 subscription='pending'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
60 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
61 subscription = pubsub.Subscription.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
62 self.assertEqual('test', subscription.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
63 self.assertEqual(JID('user@example.org/Home'), subscription.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
64 self.assertEqual('pending', subscription.state)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
65 self.assertIdentical(None, subscription.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
66
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
67
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
68 def test_fromElementWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
69 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
70 A subscription identifier in the subscription should be parsed, too.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
71 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
72 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
73 <subscription node='test' jid='user@example.org/Home' subid='1234'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
74 subscription='pending'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
75 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
76 subscription = pubsub.Subscription.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
77 self.assertEqual('1234', subscription.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
78
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
79
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
80 def test_toElement(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
81 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
82 Rendering a Subscription should yield the proper attributes.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
83 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
84 subscription = pubsub.Subscription('test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
85 JID('user@example.org/Home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
86 'pending')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
87 element = subscription.toElement()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
88 self.assertEqual('subscription', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
89 self.assertEqual(None, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
90 self.assertEqual('test', element.getAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
91 self.assertEqual('user@example.org/Home', element.getAttribute('jid'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
92 self.assertEqual('pending', element.getAttribute('subscription'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
93 self.assertFalse(element.hasAttribute('subid'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
94
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
95
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
96 def test_toElementEmptyNodeIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
97 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
98 The empty node identifier should not yield a node attribute.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
99 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
100 subscription = pubsub.Subscription('',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
101 JID('user@example.org/Home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
102 'pending')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
103 element = subscription.toElement()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
104 self.assertFalse(element.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
105
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
106
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
107 def test_toElementWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
108 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
109 The subscription identifier, if set, is in the subid attribute.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
110 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
111 subscription = pubsub.Subscription('test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
112 JID('user@example.org/Home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
113 'pending',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
114 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
115 element = subscription.toElement()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
116 self.assertEqual('1234', element.getAttribute('subid'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
117
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
118
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
119
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
120 class PubSubClientTest(unittest.TestCase):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
121 timeout = 2
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
122
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
123 def setUp(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
124 self.stub = XmlStreamStub()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
125 self.protocol = pubsub.PubSubClient()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
126 self.protocol.xmlstream = self.stub.xmlstream
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
127 self.protocol.connectionInitialized()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
128
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
129
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
130 def test_interface(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
131 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
132 Do instances of L{pubsub.PubSubClient} provide L{iwokkel.IPubSubClient}?
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
133 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
134 verify.verifyObject(iwokkel.IPubSubClient, self.protocol)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
135
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
136
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
137 def test_eventItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
138 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
140 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
141 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
142 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
143 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
144 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
145 items = event.addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
146 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
147 item1 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
148 item1['id'] = 'item1'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
149 item2 = items.addElement('retract')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
150 item2['id'] = 'item2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
151 item3 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
152 item3['id'] = 'item3'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
153
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
154 def itemsReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
155 self.assertEquals(JID('user@example.org/home'), event.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
156 self.assertEquals(JID('pubsub.example.org'), event.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
157 self.assertEquals('test', event.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
158 self.assertEquals([item1, item2, item3], event.items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
159
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
160 d, self.protocol.itemsReceived = calledAsync(itemsReceived)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
161 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
162 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
163
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
164
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
165 def test_eventItemsCollection(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
166 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
168 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
169 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
170 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
171 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
172 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
173 items = event.addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
174 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
175
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
176 headers = shim.Headers([('Collection', 'collection')])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
177 message.addChild(headers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
178
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
179 def itemsReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
180 self.assertEquals(JID('user@example.org/home'), event.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
181 self.assertEquals(JID('pubsub.example.org'), event.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
182 self.assertEquals('test', event.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
183 self.assertEquals({'Collection': ['collection']}, event.headers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
184
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
185 d, self.protocol.itemsReceived = calledAsync(itemsReceived)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
186 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
187 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
188
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
189
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
190 def test_eventItemsError(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
191 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
192 An error message with embedded event should not be handled.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
193
2cd4f0ab9ad1 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
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
195 being called. In general message.handled should be False.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
196 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
197 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
198 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
199 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
200 message['type'] = 'error'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
201 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
202 items = event.addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
203 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
204
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
205 class UnexpectedCall(Exception):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
206 pass
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
207
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
208 def itemsReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
209 raise UnexpectedCall("Unexpected call to itemsReceived")
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
210
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
211 self.protocol.itemsReceived = itemsReceived
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
212 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
213 self.assertFalse(message.handled)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
214
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
215
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
216 def test_eventDelete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
217 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
219 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
220 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
221 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
222 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
223 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
224 delete = event.addElement('delete')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
225 delete['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
226
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
227 def deleteReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
228 self.assertEquals(JID('user@example.org/home'), event.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
229 self.assertEquals(JID('pubsub.example.org'), event.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
230 self.assertEquals('test', event.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
231
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
232 d, self.protocol.deleteReceived = calledAsync(deleteReceived)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
233 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
234 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
235
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
236
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
237 def test_eventDeleteRedirect(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
238 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
239 Test receiving a delete event with a redirect URI.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
240 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
241 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
242 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
243 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
244 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
245 delete = event.addElement('delete')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
246 delete['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
247 uri = 'xmpp:pubsub.example.org?;node=test2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
248 delete.addElement('redirect')['uri'] = uri
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
249
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
250 def deleteReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
251 self.assertEquals(JID('user@example.org/home'), event.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
252 self.assertEquals(JID('pubsub.example.org'), event.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
253 self.assertEquals('test', event.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
254 self.assertEquals(uri, event.redirectURI)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
255
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
256 d, self.protocol.deleteReceived = calledAsync(deleteReceived)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
257 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
258 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
259
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
260
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
261 def test_event_purge(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
262 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
264 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
265 message = domish.Element((None, 'message'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
266 message['from'] = 'pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
267 message['to'] = 'user@example.org/home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
268 event = message.addElement((NS_PUBSUB_EVENT, 'event'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
269 items = event.addElement('purge')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
270 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
271
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
272 def purgeReceived(event):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
273 self.assertEquals(JID('user@example.org/home'), event.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
274 self.assertEquals(JID('pubsub.example.org'), event.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
275 self.assertEquals('test', event.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
276
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
277 d, self.protocol.purgeReceived = calledAsync(purgeReceived)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
278 self.stub.send(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
279 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
280
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
281
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
282 def test_createNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
283 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
284 Test sending create request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
285 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
286
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
287 def cb(nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
288 self.assertEquals('test', nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
289
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
290 d = self.protocol.createNode(JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
291 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
292
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
293 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
294 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
295 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
296 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
297 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
298 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
299 'create', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
300 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
301 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
302 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
303
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
304 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
305 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
306 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
307
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
308
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
309 def test_createNodeInstant(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
310 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
311 Test sending create request resulting in an instant node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
312 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
313
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
314 def cb(nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
315 self.assertEquals('test', nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
316
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
317 d = self.protocol.createNode(JID('pubsub.example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
318 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
319
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
320 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
321 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
322 'create', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
323 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
324 self.assertFalse(child.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
325
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
326 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
327 command = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
328 create = command.addElement('create')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
329 create['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
330 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
331 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
332
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
333
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
334 def test_createNodeRenamed(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
335 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
336 Test sending create request resulting in renamed node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
337 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
338
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
339 def cb(nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
340 self.assertEquals('test2', nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
341
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
342 d = self.protocol.createNode(JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
343 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
344
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
345 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
346 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
347 'create', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
348 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
349 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
350
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
351 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
352 command = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
353 create = command.addElement('create')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
354 create['node'] = 'test2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
355 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
356 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
357
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
358
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
359 def test_createNodeWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
360 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
361 Test sending create request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
362 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
363
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
364 d = self.protocol.createNode(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
365 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
366
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
367 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
368 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
369
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
370 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
371 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
372 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
373
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
374
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
375 def test_createNodeWithConfig(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
376 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
377 Test sending create request with configuration options
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
378 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
379
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
380 options = {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
381 'pubsub#title': 'Princely Musings (Atom)',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
382 'pubsub#deliver_payloads': True,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
383 'pubsub#persist_items': '1',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
384 'pubsub#max_items': '10',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
385 'pubsub#access_model': 'open',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
386 'pubsub#type': 'http://www.w3.org/2005/Atom',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
387 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
388
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
389 d = self.protocol.createNode(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
390 sender=JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
391 options=options)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
392
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
393 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
394
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
395 # check if there is exactly one configure element
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
396 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
397 'configure', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
398 self.assertEqual(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
399
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
400 # check that it has a configuration form
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
401 form = data_form.findForm(children[0], NS_PUBSUB_NODE_CONFIG)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
402 self.assertEqual('submit', form.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
403
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
404
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
405 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
406 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
407 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
408
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
409
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
410 def test_deleteNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
411 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
412 Test sending delete request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
413 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
414
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
415 d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
416
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
417 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
418 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
419 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
420 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
421 self.assertEquals(NS_PUBSUB_OWNER, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
422 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
423 'delete', NS_PUBSUB_OWNER))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
424 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
425 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
426 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
427
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
428 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
429 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
430 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
431
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
432
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
433 def test_deleteNodeWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
434 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
435 Test sending delete request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
436 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
437
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
438 d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
439 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
440
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
441 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
442 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
443
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
444 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
445 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
446 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
447
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
448
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
449 def test_publish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
450 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
451 Test sending publish request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
452 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
453
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
454 item = pubsub.Item()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
455 d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
456
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
457 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
458 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
459 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
460 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
461 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
462 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
463 'publish', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
464 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
465 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
466 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
467 items = list(domish.generateElementsQNamed(child.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
468 'item', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
469 self.assertEquals(1, len(items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
470 self.assertIdentical(item, items[0])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
471
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
472 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
473 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
474 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
475
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
476
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
477 def test_publishNoItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
478 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
479 Test sending publish request without items.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
480 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
481
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
482 d = self.protocol.publish(JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
483
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
484 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
485 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
486 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
487 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
488 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
489 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
490 'publish', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
491 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
492 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
493 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
494
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
495 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
496 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
497 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
498
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
499
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
500 def test_publishWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
501 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
502 Test sending publish request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
503 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
504
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
505 item = pubsub.Item()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
506 d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item],
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
507 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
508
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
509 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
510 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
511
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
512 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
513 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
514 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
515
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
516
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
517 def test_subscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
518 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
519 Test sending subscription request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
520 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
521 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
522 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
523
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
524 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
525 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
526 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
527 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
528 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
529 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
530 'subscribe', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
531 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
532 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
533 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
534 self.assertEquals('user@example.org', child['jid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
535
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
536 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
537 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
538 subscription = pubsub.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
539 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
540 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
541 subscription['subscription'] = 'subscribed'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
542 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
543 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
544
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
545
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
546 def test_subscribeReturnsSubscription(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
547 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
548 A successful subscription should return a Subscription instance.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
549 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
550 def cb(subscription):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
551 self.assertEqual(JID('user@example.org'), subscription.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
552
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
553 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
554 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
555 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
556
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
557 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
558
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
559 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
560 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
561 subscription = pubsub.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
562 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
563 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
564 subscription['subscription'] = 'subscribed'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
565 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
566 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
567
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
568
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
569 def test_subscribePending(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
570 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
571 Test sending subscription request that results in a pending
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
572 subscription.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
573 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
574 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
575 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
576
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
577 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
578 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
579 command = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
580 subscription = command.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
581 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
582 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
583 subscription['subscription'] = 'pending'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
584 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
585 self.assertFailure(d, pubsub.SubscriptionPending)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
586 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
587
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
588
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
589 def test_subscribeUnconfigured(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
590 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
591 Test sending subscription request that results in an unconfigured
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
592 subscription.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
593 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
594 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
595 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
596
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
597 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
598 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
599 command = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
600 subscription = command.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
601 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
602 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
603 subscription['subscription'] = 'unconfigured'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
604 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
605 self.assertFailure(d, pubsub.SubscriptionUnconfigured)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
606 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
607
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
608
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
609 def test_subscribeWithOptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
610 options = {'pubsub#deliver': False}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
611
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
612 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
613 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
614 options=options)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
615 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
616
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
617 # Check options present
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
618 childNames = []
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
619 for element in iq.pubsub.elements():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
620 if element.uri == NS_PUBSUB:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
621 childNames.append(element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
622
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
623 self.assertEqual(['subscribe', 'options'], childNames)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
624 form = data_form.findForm(iq.pubsub.options,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
625 NS_PUBSUB_SUBSCRIBE_OPTIONS)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
626 self.assertEqual('submit', form.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
627 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
628 self.assertEqual(options, form.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
629
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
630 # Send response
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
631 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
632 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
633 subscription = pubsub.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
634 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
635 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
636 subscription['subscription'] = 'subscribed'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
637 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
638
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
639 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
640
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
641
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
642 def test_subscribeWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
643 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
644 Test sending subscription request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
645 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
646 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
647 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
648 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
649
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
650 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
651 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
652
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
653 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
654 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
655 subscription = pubsub.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
656 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
657 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
658 subscription['subscription'] = 'subscribed'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
659 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
660 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
661
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
662
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
663 def test_subscribeReturningSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
664 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
665 Test sending subscription request with subscription identifier.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
666 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
667 def cb(subscription):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
668 self.assertEqual('1234', subscription.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
669
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
670 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
671 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
672 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
673
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
674 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
675
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
676 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
677 pubsub = response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
678 subscription = pubsub.addElement('subscription')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
679 subscription['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
680 subscription['jid'] = 'user@example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
681 subscription['subscription'] = 'subscribed'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
682 subscription['subid'] = '1234'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
683 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
684 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
685
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
686
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
687 def test_unsubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
688 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
689 Test sending unsubscription request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
690 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
691 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
692 JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
693
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
694 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
695 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
696 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
697 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
698 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
699 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
700 'unsubscribe', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
701 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
702 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
703 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
704 self.assertEquals('user@example.org', child['jid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
705
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
706 self.stub.send(toResponse(iq, 'result'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
707 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
708
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
709
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
710 def test_unsubscribeWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
711 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
712 Test sending unsubscription request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
713 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
714 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
715 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
716 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
717
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
718 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
719 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
720 self.stub.send(toResponse(iq, 'result'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
721 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
722
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
723
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
724 def test_unsubscribeWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
725 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
726 Test sending unsubscription request with subscription identifier.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
727 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
728 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
729 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
730 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
731
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
732 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
733 child = iq.pubsub.unsubscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
734 self.assertEquals('1234', child['subid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
735
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
736 self.stub.send(toResponse(iq, 'result'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
737 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
738
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
739
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
740 def test_items(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
741 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
742 Test sending items request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
743 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
744 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
745 self.assertEquals([], items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
746
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
747 d = self.protocol.items(JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
748 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
749
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
750 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
751 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
752 self.assertEquals('get', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
753 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
754 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
755 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
756 'items', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
757 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
758 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
759 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
760
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
761 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
762 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
763 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
764
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
765 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
766
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
767 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
768
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
769
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
770 def test_itemsMaxItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
771 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
773 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
774 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
775 self.assertEquals(2, len(items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
776 self.assertEquals([item1, item2], items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
777
2cd4f0ab9ad1 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)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
779 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
780
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
781 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
782 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
783 self.assertEquals('get', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
784 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
785 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
786 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
787 'items', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
788 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
789 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
790 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
791 self.assertEquals('2', child['max_items'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
792
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
793 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
794 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
795 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
796 item1 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
797 item1['id'] = 'item1'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
798 item2 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
799 item2['id'] = 'item2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
800
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
801 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
802
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
803 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
804
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
805
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
806 def test_itemsWithItemIdentifiers(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
807 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
808 Test sending items request with item identifiers.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
809 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
810 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
811 self.assertEquals(2, len(items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
812 self.assertEquals([item1, item2], items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
813
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
814 d = self.protocol.items(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
815 itemIdentifiers=['item1', 'item2'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
816 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
817
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
818 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
819 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
820 self.assertEquals('get', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
821 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
822 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
823 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
824 'items', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
825 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
826 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
827 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
828 itemIdentifiers = [item.getAttribute('id') for item in
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
829 domish.generateElementsQNamed(child.children, 'item',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
830 NS_PUBSUB)]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
831 self.assertEquals(['item1', 'item2'], itemIdentifiers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
832
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
833 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
834 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
835 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
836 item1 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
837 item1['id'] = 'item1'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
838 item2 = items.addElement('item')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
839 item2['id'] = 'item2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
840
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
841 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
842
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
843 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
844
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
845
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
846 def test_itemsWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
847 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
848 Test sending items request with a subscription identifier.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
849 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
850
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
851 d = self.protocol.items(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
852 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
853
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
854 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
855 child = iq.pubsub.items
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
856 self.assertEquals('1234', child['subid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
857
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
858 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
859 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
860 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
861
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
862 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
863 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
864
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
865
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
866 def test_itemsWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
867 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
868 Test sending items request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
869 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
870
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
871 d = self.protocol.items(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
872 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
873
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
874 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
875 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
876
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
877 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
878 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
879 items['node'] = 'test'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
880
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
881 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
882 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
883
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
884
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
885 def test_retractItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
886 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
887 Test sending items retraction.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
888 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
889 d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
890 itemIdentifiers=['item1', 'item2'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
891
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
892 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
893 self.assertEquals('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
894 self.assertEquals('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
895 self.assertEquals('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
896 self.assertEquals(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
897 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
898 'retract', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
899 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
900 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
901 self.assertEquals('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
902 itemIdentifiers = [item.getAttribute('id') for item in
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
903 domish.generateElementsQNamed(child.children, 'item',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
904 NS_PUBSUB)]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
905 self.assertEquals(['item1', 'item2'], itemIdentifiers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
906
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
907 self.stub.send(toResponse(iq, 'result'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
908 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
909
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
910
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
911 def test_retractItemsWithSender(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
912 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
913 Test retracting items request from a specific JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
914 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
915 d = self.protocol.retractItems(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
916 itemIdentifiers=['item1', 'item2'],
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
917 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
918
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
919 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
920 self.assertEquals('user@example.org', iq['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
921
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
922 self.stub.send(toResponse(iq, 'result'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
923 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
924
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
925
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
926 def test_getOptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
927 def cb(form):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
928 self.assertEqual('form', form.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
929 self.assertEqual(NS_PUBSUB_SUBSCRIBE_OPTIONS, form.formNamespace)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
930 field = form.fields['pubsub#deliver']
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
931 self.assertEqual('boolean', field.fieldType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
932 self.assertIdentical(True, field.value)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
933 self.assertEqual('Enable delivery?', field.label)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
934
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
935 d = self.protocol.getOptions(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
936 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
937 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
938 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
939
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
940 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
941 self.assertEqual('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
942 self.assertEqual('get', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
943 self.assertEqual('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
944 self.assertEqual(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
945 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
946 'options', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
947 self.assertEqual(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
948 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
949 self.assertEqual('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
950
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
951 self.assertEqual(0, len(child.children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
952
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
953 # Send response
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
954 form = data_form.Form('form', formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
955 form.addField(data_form.Field('boolean', var='pubsub#deliver',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
956 label='Enable delivery?',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
957 value=True))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
958 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
959 response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
960 response.pubsub.addElement('options')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
961 response.pubsub.options.addChild(form.toElement())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
962 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
963
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
964 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
965
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
966
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
967 def test_getOptionsWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
968 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
970 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
971
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
972 d = self.protocol.getOptions(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
973 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
974 sender=JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
975 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
976
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
977 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
978 child = iq.pubsub.options
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
979 self.assertEqual('1234', child['subid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
980
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
981 # Send response
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
982 form = data_form.Form('form', formNamespace=NS_PUBSUB_SUBSCRIBE_OPTIONS)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
983 form.addField(data_form.Field('boolean', var='pubsub#deliver',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
984 label='Enable delivery?',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
985 value=True))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
986 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
987 response.addElement((NS_PUBSUB, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
988 response.pubsub.addElement('options')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
989 response.pubsub.options.addChild(form.toElement())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
990 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
991
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
992 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
993
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
994
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
995 def test_setOptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
996 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
997 setOptions should send out a options-set request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
998 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
999 options = {'pubsub#deliver': False}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1000
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1001 d = self.protocol.setOptions(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1002 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1003 options,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1004 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1005
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1006 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1007 self.assertEqual('pubsub.example.org', iq.getAttribute('to'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1008 self.assertEqual('set', iq.getAttribute('type'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1009 self.assertEqual('pubsub', iq.pubsub.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1010 self.assertEqual(NS_PUBSUB, iq.pubsub.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1011 children = list(domish.generateElementsQNamed(iq.pubsub.children,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1012 'options', NS_PUBSUB))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1013 self.assertEqual(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1014 child = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1015 self.assertEqual('test', child['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1016
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1017 form = data_form.findForm(child, NS_PUBSUB_SUBSCRIBE_OPTIONS)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1018 self.assertEqual('submit', form.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1019 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1020 self.assertEqual(options, form.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1021
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1022 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1023 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1024
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1025 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1026
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1027
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1028 def test_setOptionsWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1029 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1030 setOptions should send out a options-set request with subid.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1031 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1032 options = {'pubsub#deliver': False}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1033
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1034 d = self.protocol.setOptions(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1035 JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1036 options,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1037 subscriptionIdentifier='1234',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1038 sender=JID('user@example.org'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1039
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1040 iq = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1041 child = iq.pubsub.options
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1042 self.assertEqual('1234', child['subid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1043
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1044 form = data_form.findForm(child, NS_PUBSUB_SUBSCRIBE_OPTIONS)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1045 self.assertEqual('submit', form.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1046 form.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1047 self.assertEqual(options, form.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1048
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1049 response = toResponse(iq, 'result')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1050 self.stub.send(response)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1051
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1052 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1053
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1054
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1055 class PubSubRequestTest(unittest.TestCase):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1056
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1057 def test_fromElementUnknown(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1058 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1059 An unknown verb raises NotImplementedError.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1060 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1061
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1062 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1063 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1064 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1065 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1066 <non-existing-verb/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1067 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1068 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1069 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1070
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1071 self.assertRaises(NotImplementedError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1072 pubsub.PubSubRequest.fromElement, parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1073
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1074
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1075 def test_fromElementKnownBadCombination(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1076 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1077 Multiple verbs in an unknown configuration raises NotImplementedError.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1078 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1079
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1080 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1081 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1082 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1083 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1084 <publish/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1085 <create/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1086 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1087 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1088 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1089
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1090 self.assertRaises(NotImplementedError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1091 pubsub.PubSubRequest.fromElement, parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1092
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1093 def test_fromElementPublish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1094 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1095 Test parsing a publish request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1096 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1097
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1098 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1099 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1100 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1101 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1102 <publish node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1103 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1104 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1105 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1106
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1107 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1108 self.assertEqual('publish', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1109 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1110 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1111 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1112 self.assertEqual([], request.items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1113
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1114
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1115 def test_fromElementPublishItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1116 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1117 Test parsing a publish request with items.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1118 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1119
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1120 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1121 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1122 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1123 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1124 <publish node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1125 <item id="item1"/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1126 <item id="item2"/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1127 </publish>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1128 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1129 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1130 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1131
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1132 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1133 self.assertEqual(2, len(request.items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1134 self.assertEqual(u'item1', request.items[0]["id"])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1135 self.assertEqual(u'item2', request.items[1]["id"])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1136
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1137
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1138 def test_fromElementPublishItemsOptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1139 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1140 Test parsing a publish request with items and options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1141
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1142 Note that publishing options are not supported, but passing them
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1143 shouldn't affect processing of the publish request itself.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1144 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1145
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1146 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1147 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1148 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1149 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1150 <publish node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1151 <item id="item1"/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1152 <item id="item2"/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1153 </publish>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1154 <publish-options/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1155 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1156 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1157 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1158
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1159 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1160 self.assertEqual(2, len(request.items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1161 self.assertEqual(u'item1', request.items[0]["id"])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1162 self.assertEqual(u'item2', request.items[1]["id"])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1163
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1164 def test_fromElementPublishNoNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1165 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1167 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1168 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1169 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1170 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1171 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1172 <publish/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1173 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1174 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1175 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1176
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1177 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1178 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1179 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1180 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1181 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1182 self.assertEqual('nodeid-required', err.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1183
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1184
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1185 def test_fromElementSubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1186 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1187 Test parsing a subscription request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1188 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1189
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1190 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1191 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1192 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1193 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1194 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1195 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1196 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1197 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1198
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1199 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1200 self.assertEqual('subscribe', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1201 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1202 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1203 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1204 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1205
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1206
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1207 def test_fromElementSubscribeEmptyNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1208 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1209 Test parsing a subscription request to the root node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1210 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1211
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1212 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1213 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1214 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1215 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1216 <subscribe jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1217 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1218 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1219 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1220
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1221 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1222 self.assertEqual('', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1223
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1224
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1225 def test_fromElementSubscribeNoJID(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1226 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1228 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1229 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1230 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1231 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1232 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1233 <subscribe node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1234 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1235 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1236 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1237 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1238 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1239 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1240 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1241 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1242 self.assertEqual('jid-required', err.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1243
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1244
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1245 def test_fromElementSubscribeWithOptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1246 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1247 Test parsing a subscription request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1248 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1249
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1250 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1251 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1252 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1253 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1254 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1255 <options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1256 <x xmlns="jabber:x:data" type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1257 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1258 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1259 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1260 <field var='pubsub#deliver' type='boolean'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1261 label='Enable delivery?'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1262 <value>1</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1263 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1264 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1265 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1266 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1267 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1268 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1269
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1270 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1271 self.assertEqual('subscribe', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1272 request.options.typeCheck({'pubsub#deliver': {'type': 'boolean'}})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1273 self.assertEqual({'pubsub#deliver': True}, request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1274
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1275
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1276 def test_fromElementSubscribeWithOptionsBadFormType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1277 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1278 The options form should have the right type.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1279 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1280
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1281 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1282 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1283 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1284 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1285 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1286 <options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1287 <x xmlns="jabber:x:data" type='result'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1288 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1289 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1290 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1291 <field var='pubsub#deliver' type='boolean'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1292 label='Enable delivery?'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1293 <value>1</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1294 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1295 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1296 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1297 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1298 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1299 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1300
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1301 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1302 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1303 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1304 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1305 self.assertEqual("Unexpected form type 'result'", err.text)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1306 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1307
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1308
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1309 def test_fromElementSubscribeWithOptionsEmpty(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1310 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1311 When no (suitable) form is found, the options are empty.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1312 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1313
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1314 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1315 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1316 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1317 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1318 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1319 <options/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1320 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1321 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1322 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1323
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1324 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1325 self.assertEqual('subscribe', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1326 self.assertEqual({}, request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1327
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1328
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1329 def test_fromElementUnsubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1330 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1331 Test parsing an unsubscription request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1332 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1333
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1334 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1335 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1336 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1337 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1338 <unsubscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1339 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1340 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1341 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1342
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1343 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1344 self.assertEqual('unsubscribe', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1345 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1346 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1347 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1348 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1349
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1350
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1351 def test_fromElementUnsubscribeWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1352 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1353 Test parsing an unsubscription request with subscription identifier.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1354 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1355
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1356 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1357 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1358 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1359 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1360 <unsubscribe node='test' jid='user@example.org/Home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1361 subid='1234'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1362 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1363 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1364 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1365
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1366 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1367 self.assertEqual('1234', request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1368
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1369
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1370 def test_fromElementUnsubscribeNoJID(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1371 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1373 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1374 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1375 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1376 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1377 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1378 <unsubscribe node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1379 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1380 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1381 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1382 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1383 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1384 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1385 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1386 self.assertEqual(NS_PUBSUB_ERRORS, err.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1387 self.assertEqual('jid-required', err.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1388
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1389
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1390 def test_fromElementOptionsGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1391 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1392 Test parsing a request for getting subscription options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1393 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1394
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1395 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1396 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1397 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1398 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1399 <options node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1400 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1401 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1402 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1403
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1404 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1405 self.assertEqual('optionsGet', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1406 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1407 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1408 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1409 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1410
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1411
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1412 def test_fromElementOptionsGetWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1413 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1414 Test parsing a request for getting subscription options with subid.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1415 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1416
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1417 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1418 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1419 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1420 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1421 <options node='test' jid='user@example.org/Home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1422 subid='1234'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1423 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1424 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1425 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1426
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1427 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1428 self.assertEqual('1234', request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1429
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1430
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1431 def test_fromElementOptionsSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1432 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1433 Test parsing a request for setting subscription options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1434 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1435
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1436 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1437 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1438 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1439 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1440 <options node='test' jid='user@example.org/Home'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1441 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1442 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1443 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1444 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1445 <field var='pubsub#deliver'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1446 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1447 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1448 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1449 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1450 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1451
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1452 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1453 self.assertEqual('optionsSet', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1454 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1455 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1456 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1457 self.assertEqual(JID('user@example.org/Home'), request.subscriber)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1458 self.assertEqual({'pubsub#deliver': '1'}, request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1459
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1460
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1461 def test_fromElementOptionsSetWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1462 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1463 Test parsing a request for setting subscription options with subid.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1464 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1465
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1466 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1467 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1468 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1469 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1470 <options node='test' jid='user@example.org/Home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1471 subid='1234'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1472 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1473 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1474 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1475 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1476 <field var='pubsub#deliver'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1477 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1478 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1479 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1480 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1481 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1482
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1483 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1484 self.assertEqual('1234', request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1485
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1486
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1487 def test_fromElementOptionsSetCancel(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1488 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1489 Test parsing a request for cancelling setting subscription options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1490 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1491
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1492 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1493 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1494 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1495 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1496 <options node='test' jid='user@example.org/Home'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1497 <x xmlns='jabber:x:data' type='cancel'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1498 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1499 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1500 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1501 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1502
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1503 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1504 self.assertEqual('cancel', request.options.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1505
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1506
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1507 def test_fromElementOptionsSetBadFormType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1508 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1509 On a options set request unknown fields should be ignored.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1510 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1511
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1512 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1513 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1514 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1515 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1516 <options node='test' jid='user@example.org/Home'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1517 <x xmlns='jabber:x:data' type='result'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1518 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1519 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1520 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1521 <field var='pubsub#deliver'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1522 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1523 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1524 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1525 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1526 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1527
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1528 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1529 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1530 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1531 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1532 self.assertEqual("Unexpected form type 'result'", err.text)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1533 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1534
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1535
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1536 def test_fromElementOptionsSetNoForm(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1537 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1538 On a options set request a form is required.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1539 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1540
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1541 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1542 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1543 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1544 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1545 <options node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1546 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1547 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1548 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1549 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1550 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1551 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1552 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1553 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1554
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1555
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1556 def test_fromElementSubscriptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1557 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1558 Test parsing a request for all subscriptions.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1559 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1560
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1561 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1562 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1563 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1564 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1565 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1566 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1567 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1568 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1569
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1570 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1571 self.assertEqual('subscriptions', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1572 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1573 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1574
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1575
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1576 def test_fromElementAffiliations(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1577 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1578 Test parsing a request for all affiliations.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1579 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1580
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1581 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1582 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1583 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1584 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1585 <affiliations/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1586 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1587 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1588 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1589
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1590 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1591 self.assertEqual('affiliations', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1592 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1593 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1594
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1595
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1596 def test_fromElementCreate(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1597 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1598 Test parsing a request to create a node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1599 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1600
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1601 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1602 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1603 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1604 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1605 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1606 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1607 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1608 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1609
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1610 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1611 self.assertEqual('create', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1612 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1613 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1614 self.assertEqual('mynode', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1615 self.assertIdentical(None, request.options)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1616
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1617
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1618 def test_fromElementCreateInstant(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1619 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1620 Test parsing a request to create an instant node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1621 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1622
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1623 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1624 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1625 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1626 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1627 <create/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1628 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1629 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1630 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1631
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1632 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1633 self.assertIdentical(None, request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1634
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1635
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1636 def test_fromElementCreateConfigureEmpty(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1637 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1639 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1640
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1641 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1642 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1643 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1644 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1645 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1646 <configure/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1647 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1648 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1649 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1650
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1651 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1652 self.assertEqual({}, request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1653 self.assertEqual(u'mynode', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1654
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1655
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1656 def test_fromElementCreateConfigureEmptyWrongOrder(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1657 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1659
2cd4f0ab9ad1 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,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1661 but we should accept both orders.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1662 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1663
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1664 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1665 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1666 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1667 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1668 <configure/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1669 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1670 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1671 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1672 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1673
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1674 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1675 self.assertEqual({}, request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1676 self.assertEqual(u'mynode', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1677
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1678
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1679 def test_fromElementCreateConfigure(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1680 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1681 Test parsing a request to create a node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1682 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1683
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1684 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1685 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1686 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1687 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1688 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1689 <configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1690 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1691 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1692 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1693 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1694 <field var='pubsub#access_model'><value>open</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1695 <field var='pubsub#persist_items'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1696 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1697 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1698 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1699 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1700 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1701
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1702 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1703 values = request.options
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1704 self.assertIn('pubsub#access_model', values)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1705 self.assertEqual(u'open', values['pubsub#access_model'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1706 self.assertIn('pubsub#persist_items', values)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1707 self.assertEqual(u'0', values['pubsub#persist_items'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1708
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1709
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1710 def test_fromElementCreateConfigureBadFormType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1711 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1713 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1714
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1715 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1716 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1717 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1718 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1719 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1720 <configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1721 <x xmlns='jabber:x:data' type='result'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1722 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1723 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1724 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1725 <field var='pubsub#access_model'><value>open</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1726 <field var='pubsub#persist_items'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1727 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1728 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1729 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1730 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1731 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1732
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1733 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1734 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1735 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1736 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1737 self.assertEqual("Unexpected form type 'result'", err.text)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1738 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1739
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1740
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1741 def test_fromElementDefault(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1742 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1743 Parsing default node configuration request sets required attributes.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1744
2cd4f0ab9ad1 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}
2cd4f0ab9ad1 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'}.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1747 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1748
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1749 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1750 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1751 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1752 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1753 <default/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1754 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1755 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1756 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1757
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1758 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1759 self.assertEquals(u'default', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1760 self.assertEquals(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1761 self.assertEquals(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1762 self.assertEquals(u'leaf', request.nodeType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1763
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1764
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1765 def test_fromElementDefaultCollection(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1766 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1767 Parsing default request for collection sets nodeType to collection.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1768 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1769
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1770 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1771 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1772 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1773 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1774 <default>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1775 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1776 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1777 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1778 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1779 <field var='pubsub#node_type'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1780 <value>collection</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1781 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1782 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1783 </default>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1784
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1785 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1786 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1787 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1788
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1789 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1790 self.assertEquals('collection', request.nodeType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1791
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1792
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1793 def test_fromElementConfigureGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1794 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1795 Test parsing a node configuration get request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1796 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1797
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1798 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1799 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1800 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1801 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1802 <configure node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1803 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1804 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1805 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1806
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1807 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1808 self.assertEqual('configureGet', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1809 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1810 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1811 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1812
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1813
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1814 def test_fromElementConfigureSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1815 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1817 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1818
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1819 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1820 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1821 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1822 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1823 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1824 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1825 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1826 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1827 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1828 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1829 <field var='pubsub#persist_items'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1830 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1831 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1832 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1833 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1834 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1835
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1836 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1837 self.assertEqual('configureSet', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1838 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1839 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1840 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1841 self.assertEqual({'pubsub#deliver_payloads': '0',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1842 'pubsub#persist_items': '1'},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1843 request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1844
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1845
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1846 def test_fromElementConfigureSetCancel(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1847 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1848 The node configuration is cancelled, so no options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1849 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1850
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1851 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1852 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1853 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1854 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1855 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1856 <x xmlns='jabber:x:data' type='cancel'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1857 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1858 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1859 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1860 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1861
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1862 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1863 self.assertEqual('cancel', request.options.formType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1864
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1865
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1866 def test_fromElementConfigureSetBadFormType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1867 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1869 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1870
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1871 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1872 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1873 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1874 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1875 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1876 <x xmlns='jabber:x:data' type='result'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1877 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1878 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1879 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1880 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1881 <field var='x-myfield'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1882 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1883 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1884 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1885 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1886 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1887
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1888 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1889 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1890 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1891 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1892 self.assertEqual("Unexpected form type 'result'", err.text)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1893 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1894
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1895
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1896 def test_fromElementConfigureSetNoForm(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1897 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1898 On a node configuration set request a form is required.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1899 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1900
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1901 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1902 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1903 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1904 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1905 <configure node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1906 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1907 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1908 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1909 err = self.assertRaises(error.StanzaError,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1910 pubsub.PubSubRequest.fromElement,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1911 parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1912 self.assertEqual('bad-request', err.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1913 self.assertEqual(None, err.appCondition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1914
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1915
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1916 def test_fromElementItems(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1917 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1918 Test parsing an items request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1919 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1920 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1921 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1922 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1923 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1924 <items node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1925 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1926 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1927 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1928
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1929 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1930 self.assertEqual('items', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1931 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1932 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1933 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1934 self.assertIdentical(None, request.maxItems)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1935 self.assertIdentical(None, request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1936 self.assertEqual([], request.itemIdentifiers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1937
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1938
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1939 def test_fromElementItemsSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1940 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1941 Test parsing an items request with subscription identifier.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1942 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1943 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1944 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1945 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1946 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1947 <items node='test' subid='1234'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1948 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1949 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1950 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1951
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1952 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1953 self.assertEqual('1234', request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1954
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1955
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1956 def test_fromElementRetract(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1957 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1958 Test parsing a retract request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1959 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1960
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1961 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1962 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1963 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1964 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1965 <retract node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1966 <item id='item1'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1967 <item id='item2'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1968 </retract>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1969 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1970 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1971 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1972
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1973 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1974 self.assertEqual('retract', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1975 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1976 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1977 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1978 self.assertEqual(['item1', 'item2'], request.itemIdentifiers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1979
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1980
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1981 def test_fromElementPurge(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1982 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1983 Test parsing a purge request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1984 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1985
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1986 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1987 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1988 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1989 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1990 <purge node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1991 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1992 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1993 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1994
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1995 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1996 self.assertEqual('purge', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1997 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1998 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
1999 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2000
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2001
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2002 def test_fromElementDelete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2003 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2004 Test parsing a delete request.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2005 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2006
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2007 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2008 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2009 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2010 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2011 <delete node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2012 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2013 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2014 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2015
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2016 request = pubsub.PubSubRequest.fromElement(parseXml(xml))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2017 self.assertEqual('delete', request.verb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2018 self.assertEqual(JID('user@example.org'), request.sender)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2019 self.assertEqual(JID('pubsub.example.org'), request.recipient)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2020 self.assertEqual('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2021
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2022
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2023
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2024 class PubSubServiceTest(unittest.TestCase, TestableRequestHandlerMixin):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2025 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2026 Tests for L{pubsub.PubSubService}.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2027 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2028
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2029 def setUp(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2030 self.stub = XmlStreamStub()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2031 self.resource = pubsub.PubSubResource()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2032 self.service = pubsub.PubSubService(self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2033 self.service.send = self.stub.xmlstream.send
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2034
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2035 def test_interface(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2036 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2037 Do instances of L{pubsub.PubSubService} provide L{iwokkel.IPubSubService}?
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2038 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2039 verify.verifyObject(iwokkel.IPubSubService, self.service)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2040
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2041
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2042 def test_interfaceIDisco(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2043 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2044 Do instances of L{pubsub.PubSubService} provide L{iwokkel.IDisco}?
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2045 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2046 verify.verifyObject(iwokkel.IDisco, self.service)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2047
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2048
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2049 def test_connectionMade(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2050 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2051 Verify setup of observers in L{pubsub.connectionMade}.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2052 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2053 requests = []
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2054
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2055 def handleRequest(iq):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2056 requests.append(iq)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2057
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2058 self.service.xmlstream = self.stub.xmlstream
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2059 self.service.handleRequest = handleRequest
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2060 self.service.connectionMade()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2061
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2062 for namespace in (NS_PUBSUB, NS_PUBSUB_OWNER):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2063 for stanzaType in ('get', 'set'):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2064 iq = domish.Element((None, 'iq'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2065 iq['type'] = stanzaType
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2066 iq.addElement((namespace, 'pubsub'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2067 self.stub.xmlstream.dispatch(iq)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2068
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2069 self.assertEqual(4, len(requests))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2070
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2071
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2072 def test_getDiscoInfo(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2073 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2074 Test getDiscoInfo calls getNodeInfo and returns some minimal info.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2075 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2076 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2077 discoInfo = disco.DiscoInfo()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2078 for item in info:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2079 discoInfo.append(item)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2080 self.assertIn(('pubsub', 'service'), discoInfo.identities)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2081 self.assertIn(disco.NS_DISCO_ITEMS, discoInfo.features)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2082
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2083 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2084 JID('pubsub.example.org'), '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2085 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2086 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2087
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2088
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2089 def test_getDiscoInfoNodeType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2090 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2091 Test getDiscoInfo with node type.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2092 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2093 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2094 discoInfo = disco.DiscoInfo()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2095 for item in info:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2096 discoInfo.append(item)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2097 self.assertIn(('pubsub', 'collection'), discoInfo.identities)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2098
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2099 def getInfo(requestor, target, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2100 return defer.succeed({'type': 'collection',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2101 'meta-data': {}})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2102
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2103 self.resource.getInfo = getInfo
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2104 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2105 JID('pubsub.example.org'), '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2106 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2107 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2108
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2109
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2110 def test_getDiscoInfoMetaData(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2111 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2112 Test getDiscoInfo with returned meta data.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2113 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2114 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2115 discoInfo = disco.DiscoInfo()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2116 for item in info:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2117 discoInfo.append(item)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2118
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2119 self.assertIn(('pubsub', 'leaf'), discoInfo.identities)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2120 self.assertIn(NS_PUBSUB_META_DATA, discoInfo.extensions)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2121 form = discoInfo.extensions[NS_PUBSUB_META_DATA]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2122 self.assertIn('pubsub#node_type', form.fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2123
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2124 def getInfo(requestor, target, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2125 metaData = [{'var': 'pubsub#persist_items',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2126 'label': 'Persist items to storage',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2127 'value': True}]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2128 return defer.succeed({'type': 'leaf', 'meta-data': metaData})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2129
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2130 self.resource.getInfo = getInfo
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2131 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2132 JID('pubsub.example.org'), '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2133 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2134 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2135
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2136
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2137 def test_getDiscoInfoResourceFeatures(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2138 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2139 Test getDiscoInfo with the resource features.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2140 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2141 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2142 discoInfo = disco.DiscoInfo()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2143 for item in info:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2144 discoInfo.append(item)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2145 self.assertIn('http://jabber.org/protocol/pubsub#publish',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2146 discoInfo.features)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2147
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2148 self.resource.features = ['publish']
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2149 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2150 JID('pubsub.example.org'), '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2151 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2152 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2153
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2154
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2155 def test_getDiscoInfoBadResponse(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2156 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2158 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2159 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2160 self.assertEquals([], info)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2161 self.assertEqual(1, len(self.flushLoggedErrors(TypeError)))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2162
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2163 def getInfo(requestor, target, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2164 return defer.succeed('bad response')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2165
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2166 self.resource.getInfo = getInfo
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2167 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2168 JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2169 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2170 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2171
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2172
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2173 def test_getDiscoInfoException(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2174 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2176 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2177 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2178 self.assertEquals([], info)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2179 self.assertEqual(1, len(self.flushLoggedErrors(NotImplementedError)))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2180
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2181 def getInfo(requestor, target, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2182 return defer.fail(NotImplementedError())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2183
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2184 self.resource.getInfo = getInfo
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2185 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2186 JID('pubsub.example.org'), 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2187 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2188 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2189
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2190
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2191 def test_getDiscoItemsRoot(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2192 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2193 Test getDiscoItems on the root node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2194 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2195 def getNodes(requestor, service, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2196 return defer.succeed(['node1', 'node2'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2197
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2198 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2199 self.assertEqual(2, len(items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2200 item1, item2 = items
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2201
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2202 self.assertEqual(JID('pubsub.example.org'), item1.entity)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2203 self.assertEqual('node1', item1.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2204
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2205 self.assertEqual(JID('pubsub.example.org'), item2.entity)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2206 self.assertEqual('node2', item2.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2207
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2208 self.resource.getNodes = getNodes
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2209 d = self.service.getDiscoItems(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2210 JID('pubsub.example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2211 '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2212 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2213 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2214
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2215
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2216 def test_getDiscoItemsRootHideNodes(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2217 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2218 Test getDiscoItems on the root node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2219 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2220 def getNodes(requestor, service, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2221 raise Exception("Unexpected call to getNodes")
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2222
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2223 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2224 self.assertEqual([], items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2225
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2226 self.service.hideNodes = True
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2227 self.resource.getNodes = getNodes
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2228 d = self.service.getDiscoItems(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2229 JID('pubsub.example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2230 '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2231 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2232 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2233
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2234
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2235 def test_getDiscoItemsNonRoot(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2236 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2237 Test getDiscoItems on a non-root node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2238 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2239 def getNodes(requestor, service, nodeIdentifier):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2240 return defer.succeed(['node1', 'node2'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2241
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2242 def cb(items):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2243 self.assertEqual(2, len(items))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2244
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2245 self.resource.getNodes = getNodes
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2246 d = self.service.getDiscoItems(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2247 JID('pubsub.example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2248 'test')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2249 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2250 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2251
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2252
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2253 def test_on_publish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2254 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2255 A publish request should result in L{PubSubService.publish} being
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2256 called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2257 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2258
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2259 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2260 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2261 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2262 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2263 <publish node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2264 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2265 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2266 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2267
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2268 def publish(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2269 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2270
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2271 self.resource.publish = publish
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2272 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2273 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2274
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2275
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2276 def test_on_subscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2277 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2278 A successful subscription should return the current subscription.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2279 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2280
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2281 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2282 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2283 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2284 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2285 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2286 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2287 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2288 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2289
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2290 def subscribe(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2291 return defer.succeed(pubsub.Subscription(request.nodeIdentifier,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2292 request.subscriber,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2293 'subscribed'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2294
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2295 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2296 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2297 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2298 subscription = element.subscription
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2299 self.assertEqual(NS_PUBSUB, subscription.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2300 self.assertEqual('test', subscription['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2301 self.assertEqual('user@example.org/Home', subscription['jid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2302 self.assertEqual('subscribed', subscription['subscription'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2303
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2304 self.resource.subscribe = subscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2305 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2306 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2307 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2308 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2309
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2310
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2311 def test_on_subscribeEmptyNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2312 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2314 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2315
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2316 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2317 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2318 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2319 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2320 <subscribe jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2321 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2322 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2323 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2324
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2325 def subscribe(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2326 return defer.succeed(pubsub.Subscription(request.nodeIdentifier,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2327 request.subscriber,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2328 'subscribed'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2329
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2330 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2331 self.assertFalse(element.subscription.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2332
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2333 self.resource.subscribe = subscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2334 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2335 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2336 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2337 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2338
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2339
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2340 def test_on_subscribeSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2341 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2342 If a subscription returns a subid, this should be available.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2343 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2344
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2345 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2346 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2347 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2348 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2349 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2350 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2351 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2352 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2353
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2354 def subscribe(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2355 subscription = pubsub.Subscription(request.nodeIdentifier,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2356 request.subscriber,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2357 'subscribed',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2358 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2359 return defer.succeed(subscription)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2360
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2361 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2362 self.assertEqual('1234', element.subscription.getAttribute('subid'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2363
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2364 self.resource.subscribe = subscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2365 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2366 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2367 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2368 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2369
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2370
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2371 def test_on_unsubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2372 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2373 A successful unsubscription should return an empty response.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2374 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2375
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2376 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2377 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2378 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2379 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2380 <unsubscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2381 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2382 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2383 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2384
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2385 def unsubscribe(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2386 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2387
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2388 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2389 self.assertIdentical(None, element)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2390
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2391 self.resource.unsubscribe = unsubscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2392 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2393 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2394 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2395 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2396
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2397
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2398 def test_on_unsubscribeSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2399 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2400 A successful unsubscription with subid should return an empty response.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2401 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2402
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2403 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2404 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2405 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2406 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2407 <unsubscribe node='test' jid='user@example.org/Home' subid='1234'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2408 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2409 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2410 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2411
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2412 def unsubscribe(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2413 self.assertEqual('1234', request.subscriptionIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2414 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2415
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2416 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2417 self.assertIdentical(None, element)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2418
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2419 self.resource.unsubscribe = unsubscribe
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2420 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2421 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2422 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2423 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2424
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2425
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2426 def test_on_optionsGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2427 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2428 Getting subscription options is not supported.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2429 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2430
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2431 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2432 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2433 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2434 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2435 <options node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2436 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2437 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2438 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2439
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2440 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2441 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2442 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2443 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2444
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2445 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2446 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2447 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2448 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2449
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2450
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2451 def test_on_optionsSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2452 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2453 Setting subscription options is not supported.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2454 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2455
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2456 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2457 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2458 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2459 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2460 <options node='test' jid='user@example.org/Home'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2461 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2462 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2463 <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2464 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2465 <field var='pubsub#deliver'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2466 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2467 </options>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2468 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2469 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2470 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2471
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2472 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2473 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2474 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2475 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2476
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2477 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2478 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2479 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2480 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2481
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2482
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2483 def test_on_subscriptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2484 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2485 A subscriptions request should result in
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2486 L{PubSubService.subscriptions} being called and the result prepared
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2487 for the response.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2488 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2489
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2490 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2491 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2492 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2493 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2494 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2495 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2496 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2497 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2498
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2499 def subscriptions(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2500 subscription = pubsub.Subscription('test', JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2501 'subscribed')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2502 return defer.succeed([subscription])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2503
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2504 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2505 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2506 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2507 self.assertEqual(NS_PUBSUB, element.subscriptions.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2508 children = list(element.subscriptions.elements())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2509 self.assertEqual(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2510 subscription = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2511 self.assertEqual('subscription', subscription.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2512 self.assertEqual(NS_PUBSUB, subscription.uri, NS_PUBSUB)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2513 self.assertEqual('user@example.org', subscription['jid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2514 self.assertEqual('test', subscription['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2515 self.assertEqual('subscribed', subscription['subscription'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2516
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2517 self.resource.subscriptions = subscriptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2518 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2519 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2520 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2521 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2522
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2523
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2524 def test_on_subscriptionsWithSubscriptionIdentifier(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2525 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2526 A subscriptions request response should include subids, if set.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2527 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2528
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2529 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2530 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2531 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2532 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2533 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2534 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2535 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2536 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2537
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2538 def subscriptions(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2539 subscription = pubsub.Subscription('test', JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2540 'subscribed',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2541 subscriptionIdentifier='1234')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2542 return defer.succeed([subscription])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2543
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2544 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2545 subscription = element.subscriptions.subscription
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2546 self.assertEqual('1234', subscription['subid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2547
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2548 self.resource.subscriptions = subscriptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2549 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2550 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2551 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2552 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2553
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2554
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2555 def test_on_affiliations(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2556 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2557 A subscriptions request should result in
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2558 L{PubSubService.affiliations} being called and the result prepared
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2559 for the response.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2560 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2561
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2562 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2563 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2564 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2565 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2566 <affiliations/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2567 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2568 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2569 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2570
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2571 def affiliations(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2572 affiliation = ('test', 'owner')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2573 return defer.succeed([affiliation])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2574
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2575 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2576 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2577 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2578 self.assertEqual(NS_PUBSUB, element.affiliations.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2579 children = list(element.affiliations.elements())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2580 self.assertEqual(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2581 affiliation = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2582 self.assertEqual('affiliation', affiliation.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2583 self.assertEqual(NS_PUBSUB, affiliation.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2584 self.assertEqual('test', affiliation['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2585 self.assertEqual('owner', affiliation['affiliation'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2586
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2587 self.resource.affiliations = affiliations
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2588 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2589 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2590 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2591 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2592
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2593
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2594 def test_on_create(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2595 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2597 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2598
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2599 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2600 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2601 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2602 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2603 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2604 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2605 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2606 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2607
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2608 def create(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2609 return defer.succeed(request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2610
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2611 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2612 self.assertIdentical(None, element)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2613
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2614 self.resource.create = create
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2615 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2616 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2617 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2618 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2619
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2620
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2621 def test_on_createChanged(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2622 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2624 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2625
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2626 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2627 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2628 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2629 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2630 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2631 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2632 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2633 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2634
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2635 def create(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2636 return defer.succeed(u'myrenamednode')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2637
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2638 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2639 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2640 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2641 self.assertEqual(NS_PUBSUB, element.create.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2642 self.assertEqual(u'myrenamednode',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2643 element.create.getAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2644
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2645 self.resource.create = create
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2646 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2647 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2648 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2649 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2650
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2651
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2652 def test_on_createInstant(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2653 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2654 Replies to create instant node requests return the created node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2655 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2656
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2657 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2658 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2659 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2660 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2661 <create/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2662 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2663 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2664 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2665
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2666 def create(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2667 return defer.succeed(u'random')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2668
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2669 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2670 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2671 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2672 self.assertEqual(NS_PUBSUB, element.create.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2673 self.assertEqual(u'random', element.create.getAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2674
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2675 self.resource.create = create
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2676 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2677 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2678 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2679 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2680
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2681
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2682 def test_on_createWithConfig(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2683 """
2cd4f0ab9ad1 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
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2685 L{PubSubResource.create} is called with the passed options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2686 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2687
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2688 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2689 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2690 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2691 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2692 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2693 <configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2694 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2695 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2696 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2697 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2698 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2699 <field var='pubsub#persist_items'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2700 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2701 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2702 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2703 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2704 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2705
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2706 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2707 return {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2708 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2709 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2710 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2711 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2712 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2713 "label": "Deliver payloads with event notifications"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2714 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2715
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2716 def create(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2717 self.assertEqual({'pubsub#deliver_payloads': False,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2718 'pubsub#persist_items': True},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2719 request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2720 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2721
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2722 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2723 self.resource.create = create
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2724 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2725 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2726
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2727
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2728 def test_on_default(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2729 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2730 A default request returns default options filtered by available fields.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2731 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2732
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2733 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2734 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2735 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2736 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2737 <default/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2738 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2739 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2740 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2741 fieldDefs = {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2742 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2743 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2744 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2745 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2746 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2747 "label": "Deliver payloads with event notifications"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2748 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2749
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2750 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2751 return fieldDefs
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2752
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2753 def default(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2754 return defer.succeed({'pubsub#persist_items': 'false',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2755 'x-myfield': '1'})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2756
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2757 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2758 self.assertEquals('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2759 self.assertEquals(NS_PUBSUB_OWNER, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2760 self.assertEquals(NS_PUBSUB_OWNER, element.default.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2761 form = data_form.Form.fromElement(element.default.x)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2762 self.assertEquals(NS_PUBSUB_NODE_CONFIG, form.formNamespace)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2763 form.typeCheck(fieldDefs)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2764 self.assertIn('pubsub#persist_items', form.fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2765 self.assertFalse(form.fields['pubsub#persist_items'].value)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2766 self.assertNotIn('x-myfield', form.fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2767
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2768 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2769 self.resource.default = default
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2770 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2771 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2772 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2773 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2774
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2775
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2776 def test_on_defaultUnknownNodeType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2777 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2778 Unknown node types yield non-acceptable.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2779
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2780 Both C{getConfigurationOptions} and C{default} must not be called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2781 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2782
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2783 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2784 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2785 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2786 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2787 <default>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2788 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2789 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2790 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2791 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2792 <field var='pubsub#node_type'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2793 <value>unknown</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2794 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2795 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2796 </default>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2797
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2798 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2799 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2800 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2801
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2802 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2803 self.fail("Unexpected call to getConfigurationOptions")
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2804
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2805 def default(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2806 self.fail("Unexpected call to default")
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2807
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2808 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2809 self.assertEquals('not-acceptable', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2810
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2811 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2812 self.resource.default = default
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2813 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2814 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2815 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2816 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2817 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2818
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2819
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2820 def test_on_configureGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2821 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2822 On a node configuration get
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2823 requestL{PubSubResource.configureGet} is called and results in a
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2824 data form with the configuration.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2825 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2826
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2827 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2828 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2829 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2830 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2831 <configure node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2832 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2833 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2834 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2835
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2836 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2837 return {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2838 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2839 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2840 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2841 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2842 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2843 "label": "Deliver payloads with event notifications"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2844 "pubsub#owner":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2845 {"type": "jid-single",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2846 "label": "Owner of the node"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2847 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2848
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2849 def configureGet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2850 return defer.succeed({'pubsub#deliver_payloads': '0',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2851 'pubsub#persist_items': '1',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2852 'pubsub#owner': JID('user@example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2853 'x-myfield': 'a'})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2854
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2855 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2856 self.assertEqual('pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2857 self.assertEqual(NS_PUBSUB_OWNER, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2858 self.assertEqual(NS_PUBSUB_OWNER, element.configure.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2859 form = data_form.Form.fromElement(element.configure.x)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2860 self.assertEqual(NS_PUBSUB_NODE_CONFIG, form.formNamespace)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2861 fields = form.fields
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2862
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2863 self.assertIn('pubsub#deliver_payloads', fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2864 field = fields['pubsub#deliver_payloads']
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2865 self.assertEqual('boolean', field.fieldType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2866 field.typeCheck()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2867 self.assertEqual(False, field.value)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2868
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2869 self.assertIn('pubsub#persist_items', fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2870 field = fields['pubsub#persist_items']
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2871 self.assertEqual('boolean', field.fieldType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2872 field.typeCheck()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2873 self.assertEqual(True, field.value)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2874
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2875 self.assertIn('pubsub#owner', fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2876 field = fields['pubsub#owner']
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2877 self.assertEqual('jid-single', field.fieldType)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2878 field.typeCheck()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2879 self.assertEqual(JID('user@example.org'), field.value)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2880
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2881 self.assertNotIn('x-myfield', fields)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2882
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2883 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2884 self.resource.configureGet = configureGet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2885 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2886 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2887 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2888 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2889
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2890
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2891 def test_on_configureSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2892 """
2cd4f0ab9ad1 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
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2894 L{PubSubResource.configureSet} is called with the passed options.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2895 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2896
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2897 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2898 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2899 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2900 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2901 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2902 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2903 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2904 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2905 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2906 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2907 <field var='pubsub#persist_items'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2908 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2909 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2910 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2911 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2912 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2913
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2914 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2915 return {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2916 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2917 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2918 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2919 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2920 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2921 "label": "Deliver payloads with event notifications"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2922 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2923
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2924 def configureSet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2925 self.assertEqual({'pubsub#deliver_payloads': False,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2926 'pubsub#persist_items': True},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2927 request.options.getValues())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2928 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2929
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2930 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2931 self.resource.configureSet = configureSet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2932 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2933 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2934
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2935
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2936 def test_on_configureSetCancel(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2937 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2938 The node configuration is cancelled,
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2939 L{PubSubResource.configureSet} not called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2940 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2941
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2942 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2943 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2944 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2945 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2946 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2947 <x xmlns='jabber:x:data' type='cancel'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2948 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2949 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2950 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2951 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2952 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2953 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2954 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2955 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2956
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2957 def configureSet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2958 self.fail("Unexpected call to setConfiguration")
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2959
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2960 self.resource.configureSet = configureSet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2961 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2962 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2963
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2964
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2965 def test_on_configureSetIgnoreUnknown(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2966 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2968 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2969
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2970 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2971 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2972 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2973 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2974 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2975 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2976 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2977 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2978 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2979 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2980 <field var='x-myfield'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2981 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2982 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2983 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2984 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2985 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2986
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2987 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2988 return {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2989 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2990 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2991 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2992 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2993 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2994 "label": "Deliver payloads with event notifications"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2995 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2996
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2997 def configureSet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2998 self.assertEquals(['pubsub#deliver_payloads'],
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
2999 request.options.keys())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3000
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3001 self.resource.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3002 self.resource.configureSet = configureSet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3003 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3004 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3005
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3006
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3007 def test_on_configureSetBadFormType(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3008 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3010 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3011
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3012 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3013 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3014 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3015 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3016 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3017 <x xmlns='jabber:x:data' type='result'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3018 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3019 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3020 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3021 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3022 <field var='x-myfield'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3023 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3024 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3025 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3026 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3027 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3028
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3029 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3030 self.assertEquals('bad-request', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3031 self.assertEqual("Unexpected form type 'result'", result.text)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3032
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3033 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3034 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3035 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3036 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3037
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3038
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3039 def test_on_items(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3040 """
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3042 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3043 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3044 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3045 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3046 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3047 <items node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3048 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3049 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3050 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3051
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3052 def items(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3053 return defer.succeed([pubsub.Item('current')])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3054
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3055 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3056 self.assertEqual(NS_PUBSUB, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3057 self.assertEqual(NS_PUBSUB, element.items.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3058 self.assertEqual(1, len(element.items.children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3059 item = element.items.children[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3060 self.assertTrue(domish.IElement.providedBy(item))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3061 self.assertEqual('item', item.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3062 self.assertEqual(NS_PUBSUB, item.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3063 self.assertEqual('current', item['id'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3064
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3065 self.resource.items = items
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3066 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3067 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3068 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3069 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3070
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3071
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3072 def test_on_retract(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3073 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3074 A retract request should result in L{PubSubResource.retract}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3075 being called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3076 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3077
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3078 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3079 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3080 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3081 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3082 <retract node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3083 <item id='item1'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3084 <item id='item2'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3085 </retract>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3086 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3087 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3088 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3089
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3090 def retract(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3091 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3092
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3093 self.resource.retract = retract
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3094 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3095 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3096
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3097
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3098 def test_on_purge(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3099 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3100 A purge request should result in L{PubSubResource.purge} being
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3101 called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3102 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3103
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3104 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3105 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3106 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3107 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3108 <purge node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3109 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3110 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3111 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3112
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3113 def purge(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3114 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3115
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3116 self.resource.purge = purge
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3117 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3118 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3119
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3120
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3121 def test_on_delete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3122 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3123 A delete request should result in L{PubSubResource.delete} being
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3124 called.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3125 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3126
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3127 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3128 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3129 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3130 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3131 <delete node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3132 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3133 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3134 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3135
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3136 def delete(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3137 return defer.succeed(None)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3138
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3139 self.resource.delete = delete
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3140 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3141 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3142
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3143
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3144 def test_notifyPublish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3145 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3146 Publish notifications are sent to the subscribers.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3147 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3148 subscriber = JID('user@example.org')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3149 subscriptions = [pubsub.Subscription('test', subscriber, 'subscribed')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3150 items = [pubsub.Item('current')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3151 notifications = [(subscriber, subscriptions, items)]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3152 self.service.notifyPublish(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3153 notifications)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3154 message = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3155
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3156 self.assertEquals('message', message.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3157 self.assertIdentical(None, message.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3158 self.assertEquals('user@example.org', message['to'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3159 self.assertEquals('pubsub.example.org', message['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3160 self.assertTrue(message.event)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3161 self.assertEquals(NS_PUBSUB_EVENT, message.event.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3162 self.assertTrue(message.event.items)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3163 self.assertEquals(NS_PUBSUB_EVENT, message.event.items.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3164 self.assertTrue(message.event.items.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3165 self.assertEquals('test', message.event.items['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3166 itemElements = list(domish.generateElementsQNamed(
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3167 message.event.items.children, 'item', NS_PUBSUB_EVENT))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3168 self.assertEquals(1, len(itemElements))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3169 self.assertEquals('current', itemElements[0].getAttribute('id'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3170
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3171
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3172 def test_notifyPublishCollection(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3173 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3174 Publish notifications are sent to the subscribers of collections.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3175
2cd4f0ab9ad1 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
2cd4f0ab9ad1 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.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3178 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3179 subscriber = JID('user@example.org')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3180 subscriptions = [pubsub.Subscription('', subscriber, 'subscribed')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3181 items = [pubsub.Item('current')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3182 notifications = [(subscriber, subscriptions, items)]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3183 self.service.notifyPublish(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3184 notifications)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3185 message = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3186
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3187 self.assertTrue(message.event.items.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3188 self.assertEquals('test', message.event.items['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3189 headers = shim.extractHeaders(message)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3190 self.assertIn('Collection', headers)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3191 self.assertIn('', headers['Collection'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3192
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3193
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3194 def test_notifyDelete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3195 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3196 Subscribers should be sent a delete notification.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3197 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3198 subscriptions = [JID('user@example.org')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3199 self.service.notifyDelete(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3200 subscriptions)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3201 message = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3202
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3203 self.assertEquals('message', message.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3204 self.assertIdentical(None, message.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3205 self.assertEquals('user@example.org', message['to'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3206 self.assertEquals('pubsub.example.org', message['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3207 self.assertTrue(message.event)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3208 self.assertEqual(NS_PUBSUB_EVENT, message.event.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3209 self.assertTrue(message.event.delete)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3210 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3211 self.assertTrue(message.event.delete.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3212 self.assertEqual('test', message.event.delete['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3213
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3214
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3215 def test_notifyDeleteRedirect(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3216 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3217 Subscribers should be sent a delete notification with redirect.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3218 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3219 redirectURI = 'xmpp:pubsub.example.org?;node=test2'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3220 subscriptions = [JID('user@example.org')]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3221 self.service.notifyDelete(JID('pubsub.example.org'), 'test',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3222 subscriptions, redirectURI)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3223 message = self.stub.output[-1]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3224
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3225 self.assertEquals('message', message.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3226 self.assertIdentical(None, message.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3227 self.assertEquals('user@example.org', message['to'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3228 self.assertEquals('pubsub.example.org', message['from'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3229 self.assertTrue(message.event)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3230 self.assertEqual(NS_PUBSUB_EVENT, message.event.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3231 self.assertTrue(message.event.delete)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3232 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3233 self.assertTrue(message.event.delete.hasAttribute('node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3234 self.assertEqual('test', message.event.delete['node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3235 self.assertTrue(message.event.delete.redirect)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3236 self.assertEqual(NS_PUBSUB_EVENT, message.event.delete.redirect.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3237 self.assertTrue(message.event.delete.redirect.hasAttribute('uri'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3238 self.assertEqual(redirectURI, message.event.delete.redirect['uri'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3239
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3240
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3241 def test_on_subscriptionsGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3242 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3243 Getting subscription options is not supported.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3244 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3245
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3246 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3247 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3248 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3249 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3250 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3251 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3252 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3253 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3254
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3255 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3256 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3257 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3258 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3259 self.assertEquals('manage-subscriptions',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3260 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3261
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3262 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3263 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3264 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3265 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3266
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3267
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3268 def test_on_subscriptionsSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3269 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3270 Setting subscription options is not supported.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3271 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3272
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3273 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3274 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3275 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3276 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3277 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3278 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3279 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3280 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3281
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3282 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3283 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3284 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3285 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3286 self.assertEquals('manage-subscriptions',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3287 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3288
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3289 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3290 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3291 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3292 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3293
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3294
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3295 def test_on_affiliationsGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3296 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3297 Getting node affiliations should have.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3298 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3299
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3300 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3301 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3302 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3303 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3304 <affiliations node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3305 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3306 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3307 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3308
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3309 def affiliationsGet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3310 self.assertEquals('test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3311 return defer.succeed({JID('user@example.org'): 'owner'})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3312
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3313 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3314 self.assertEquals(u'pubsub', element.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3315 self.assertEquals(NS_PUBSUB_OWNER, element.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3316 self.assertEquals(NS_PUBSUB_OWNER, element.affiliations.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3317 self.assertEquals(u'test', element.affiliations[u'node'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3318 children = list(element.affiliations.elements())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3319 self.assertEquals(1, len(children))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3320 affiliation = children[0]
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3321 self.assertEquals(u'affiliation', affiliation.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3322 self.assertEquals(NS_PUBSUB_OWNER, affiliation.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3323 self.assertEquals(u'user@example.org', affiliation[u'jid'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3324 self.assertEquals(u'owner', affiliation[u'affiliation'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3325
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3326 self.resource.affiliationsGet = affiliationsGet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3327 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3328 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3329 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3330 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3331
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3332
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3333 def test_on_affiliationsGetEmptyNode(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3334 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3335 Getting node affiliations without node should assume empty node.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3336 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3337
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3338 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3339 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3340 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3341 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3342 <affiliations/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3343 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3344 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3345 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3346
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3347 def affiliationsGet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3348 self.assertEqual('', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3349 return defer.succeed({})
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3350
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3351 def cb(element):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3352 self.assertFalse(element.affiliations.hasAttribute(u'node'))
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3353
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3354 self.resource.affiliationsGet = affiliationsGet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3355 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3356 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3357 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3358 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3359
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3360
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3361 def test_on_affiliationsSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3362 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3363 Setting node affiliations has the affiliations to be modified.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3364 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3365
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3366 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3367 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3368 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3369 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3370 <affiliations node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3371 <affiliation jid='other@example.org' affiliation='publisher'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3372 </affiliations>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3373 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3374 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3375 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3376
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3377 def affiliationsSet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3378 self.assertEquals(u'test', request.nodeIdentifier)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3379 otherJID = JID(u'other@example.org')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3380 self.assertIn(otherJID, request.affiliations)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3381 self.assertEquals(u'publisher', request.affiliations[otherJID])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3382
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3383 self.resource.affiliationsSet = affiliationsSet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3384 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3385
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3386
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3387 def test_on_affiliationsSetBareJID(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3388 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3389 Affiliations are always on the bare JID.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3390 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3391
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3392 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3393 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3394 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3395 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3396 <affiliations node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3397 <affiliation jid='other@example.org/Home'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3398 affiliation='publisher'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3399 </affiliations>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3400 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3401 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3402 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3403
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3404 def affiliationsSet(request):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3405 otherJID = JID(u'other@example.org')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3406 self.assertIn(otherJID, request.affiliations)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3407
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3408 self.resource.affiliationsSet = affiliationsSet
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3409 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3410
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3411
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3412 def test_on_affiliationsSetMultipleForSameEntity(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3413 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3414 Setting node affiliations can only have one item per entity.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3415 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3416
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3417 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3418 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3419 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3420 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3421 <affiliations node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3422 <affiliation jid='other@example.org' affiliation='publisher'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3423 <affiliation jid='other@example.org' affiliation='owner'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3424 </affiliations>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3425 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3426 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3427 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3428
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3429 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3430 self.assertEquals('bad-request', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3431
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3432 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3433 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3434 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3435 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3436
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3437
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3438 def test_on_affiliationsSetMissingJID(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3439 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3440 Setting node affiliations must include a JID per affiliation.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3441 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3442
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3443 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3444 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3445 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3446 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3447 <affiliations node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3448 <affiliation affiliation='publisher'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3449 </affiliations>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3450 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3451 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3452 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3453
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3454 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3455 self.assertEquals('bad-request', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3456
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3457 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3458 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3459 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3460 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3461
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3462
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3463 def test_on_affiliationsSetMissingAffiliation(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3464 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3465 Setting node affiliations must include an affiliation.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3466 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3467
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3468 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3469 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3470 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3471 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3472 <affiliations node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3473 <affiliation jid='other@example.org'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3474 </affiliations>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3475 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3476 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3477 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3478
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3479 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3480 self.assertEquals('bad-request', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3481
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3482 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3483 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3484 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3485 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3486
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3487
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3488
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3489 class PubSubServiceWithoutResourceTest(unittest.TestCase, TestableRequestHandlerMixin):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3490
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3491 def setUp(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3492 self.stub = XmlStreamStub()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3493 self.service = pubsub.PubSubService()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3494 self.service.send = self.stub.xmlstream.send
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3495
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3496
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3497 def test_getDiscoInfo(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3498 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3499 Test getDiscoInfo calls getNodeInfo and returns some minimal info.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3500 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3501 def cb(info):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3502 discoInfo = disco.DiscoInfo()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3503 for item in info:
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3504 discoInfo.append(item)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3505 self.assertIn(('pubsub', 'service'), discoInfo.identities)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3506 self.assertIn(disco.NS_DISCO_ITEMS, discoInfo.features)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3507
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3508 d = self.service.getDiscoInfo(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3509 JID('pubsub.example.org'), '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3510 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3511 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3512
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3513
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3514 def test_publish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3515 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3516 Non-overridden L{PubSubService.publish} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3517 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3518
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3519 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3520 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3521 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3522 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3523 <publish node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3524 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3525 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3526 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3527
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3528 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3529 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3530 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3531 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3532 self.assertEquals('publish', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3533
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3534 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3535 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3536 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3537 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3538
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3539
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3540 def test_subscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3541 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3542 Non-overridden L{PubSubService.subscribe} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3543 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3544
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3545 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3546 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3547 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3548 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3549 <subscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3550 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3551 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3552 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3553
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3554 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3555 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3556 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3557 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3558 self.assertEquals('subscribe', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3559
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3560 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3561 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3562 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3563 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3564
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3565
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3566 def test_unsubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3567 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3568 Non-overridden L{PubSubService.unsubscribe} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3569 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3570
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3571 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3572 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3573 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3574 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3575 <unsubscribe node='test' jid='user@example.org/Home'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3576 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3577 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3578 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3579
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3580 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3581 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3582 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3583 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3584 self.assertEquals('subscribe', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3585
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3586 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3587 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3588 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3589 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3590
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3591
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3592 def test_subscriptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3593 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3594 Non-overridden L{PubSubService.subscriptions} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3595 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3596
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3597 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3598 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3599 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3600 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3601 <subscriptions/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3602 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3603 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3604 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3605
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3606 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3607 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3608 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3609 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3610 self.assertEquals('retrieve-subscriptions',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3611 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3612
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3613 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3614 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3615 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3616 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3617
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3618
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3619 def test_affiliations(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3620 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3621 Non-overridden L{PubSubService.affiliations} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3622 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3623
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3624 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3625 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3626 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3627 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3628 <affiliations/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3629 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3630 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3631 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3632
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3633 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3634 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3635 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3636 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3637 self.assertEquals('retrieve-affiliations',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3638 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3639
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3640 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3641 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3642 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3643 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3644
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3645
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3646 def test_create(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3647 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3648 Non-overridden L{PubSubService.create} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3649 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3650
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3651 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3652 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3653 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3654 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3655 <create node='mynode'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3656 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3657 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3658 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3659
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3660 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3661 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3662 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3663 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3664 self.assertEquals('create-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3665
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3666 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3667 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3668 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3669 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3670
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3671
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3672 def test_getDefaultConfiguration(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3673 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3674 Non-overridden L{PubSubService.getDefaultConfiguration} yields
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3675 unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3676 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3677
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3678 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3679 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3680 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3681 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3682 <default/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3683 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3684 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3685 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3686
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3687 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3688 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3689 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3690 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3691 self.assertEquals('retrieve-default', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3692
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3693 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3694 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3695 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3696 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3697
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3698
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3699 def test_getConfiguration(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3700 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3701 Non-overridden L{PubSubService.getConfiguration} yields unsupported
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3702 error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3703 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3704
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3705 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3706 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3707 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3708 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3709 <configure/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3710 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3711 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3712 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3713
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3714 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3715 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3716 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3717 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3718 self.assertEquals('config-node', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3719
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3720 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3721 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3722 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3723 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3724
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3725
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3726 def test_setConfiguration(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3727 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3728 Non-overridden L{PubSubService.setConfiguration} yields unsupported
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3729 error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3730 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3731
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3732 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3733 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3734 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3735 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3736 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3737 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3738 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3739 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3740 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3741 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3742 <field var='pubsub#persist_items'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3743 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3744 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3745 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3746 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3747 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3748
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3749 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3750 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3751 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3752 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3753 self.assertEquals('config-node', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3754
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3755 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3756 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3757 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3758 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3759
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3760
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3761 def test_setConfigurationOptionsDict(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3762 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3763 Options should be passed as a dictionary, not a form.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3764 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3765
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3766 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3767 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3768 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3769 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3770 <configure node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3771 <x xmlns='jabber:x:data' type='submit'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3772 <field var='FORM_TYPE' type='hidden'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3773 <value>http://jabber.org/protocol/pubsub#node_config</value>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3774 </field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3775 <field var='pubsub#deliver_payloads'><value>0</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3776 <field var='pubsub#persist_items'><value>1</value></field>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3777 </x>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3778 </configure>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3779 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3780 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3781 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3782
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3783 def getConfigurationOptions():
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3784 return {
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3785 "pubsub#persist_items":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3786 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3787 "label": "Persist items to storage"},
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3788 "pubsub#deliver_payloads":
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3789 {"type": "boolean",
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3790 "label": "Deliver payloads with event notifications"}
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3791 }
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3792
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3793 def setConfiguration(requestor, service, nodeIdentifier, options):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3794 self.assertIn('pubsub#deliver_payloads', options)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3795 self.assertFalse(options['pubsub#deliver_payloads'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3796 self.assertIn('pubsub#persist_items', options)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3797 self.assertTrue(options['pubsub#persist_items'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3798
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3799 self.service.getConfigurationOptions = getConfigurationOptions
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3800 self.service.setConfiguration = setConfiguration
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3801 return self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3802
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3803
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3804 def test_items(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3805 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3806 Non-overridden L{PubSubService.items} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3807 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3808 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3809 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3810 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3811 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3812 <items node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3813 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3814 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3815 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3816
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3817 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3818 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3819 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3820 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3821 self.assertEquals('retrieve-items', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3822
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3823 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3824 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3825 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3826 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3827
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3828
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3829 def test_retract(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3830 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3831 Non-overridden L{PubSubService.retract} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3832 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3833 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3834 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3835 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3836 <pubsub xmlns='http://jabber.org/protocol/pubsub'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3837 <retract node='test'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3838 <item id='item1'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3839 <item id='item2'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3840 </retract>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3841 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3842 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3843 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3844
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3845 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3846 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3847 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3848 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3849 self.assertEquals('retract-items', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3850
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3851 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3852 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3853 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3854 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3855
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3856
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3857 def test_purge(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3858 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3859 Non-overridden L{PubSubService.purge} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3860 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3861 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3862 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3863 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3864 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3865 <purge node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3866 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3867 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3868 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3869
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3870 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3871 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3872 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3873 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3874 self.assertEquals('purge-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3875
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3876 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3877 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3878 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3879 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3880
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3881
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3882 def test_delete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3883 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3884 Non-overridden L{PubSubService.delete} yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3885 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3886 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3887 <iq type='set' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3888 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3889 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3890 <delete node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3891 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3892 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3893 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3894
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3895 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3896 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3897 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3898 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3899 self.assertEquals('delete-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3900
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3901 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3902 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3903 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3904 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3905
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3906
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3907 def test_unknown(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3908 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3909 Unknown verb yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3910 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3911 xml = """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3912 <iq type='get' to='pubsub.example.org'
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3913 from='user@example.org'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3914 <pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3915 <affiliations node='test'/>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3916 </pubsub>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3917 </iq>
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3918 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3919
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3920 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3921 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3922 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3923 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3924
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3925 d = self.handleRequest(xml)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3926 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3927 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3928 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3929
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3930
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3931
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3932 class PubSubResourceTest(unittest.TestCase):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3933
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3934 def setUp(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3935 self.resource = pubsub.PubSubResource()
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3936
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3937
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3938 def test_interface(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3939 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3940 Do instances of L{pubsub.PubSubResource} provide L{iwokkel.IPubSubResource}?
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3941 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3942 verify.verifyObject(iwokkel.IPubSubResource, self.resource)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3943
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3944
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3945 def test_getNodes(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3946 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3947 Default getNodes returns an empty list.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3948 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3949 def cb(nodes):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3950 self.assertEquals([], nodes)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3951
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3952 d = self.resource.getNodes(JID('user@example.org/home'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3953 JID('pubsub.example.org'),
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3954 '')
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3955 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3956 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3957
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3958
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3959 def test_publish(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3960 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3961 Non-overridden L{PubSubResource.publish} yields unsupported
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3962 error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3963 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3964
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3965 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3966 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3967 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3968 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3969 self.assertEquals('publish', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3970
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3971 d = self.resource.publish(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3972 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3973 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3974 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3975
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3976
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3977 def test_subscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3978 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3979 Non-overridden subscriptions yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3980 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3981
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3982 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3983 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3984 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3985 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3986 self.assertEquals('subscribe', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3987
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3988 d = self.resource.subscribe(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3989 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3990 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3991 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3992
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3993
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3994 def test_unsubscribe(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3995 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3996 Non-overridden unsubscribe yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3997 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3998
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
3999 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4000 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4001 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4002 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4003 self.assertEquals('subscribe', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4004
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4005 d = self.resource.unsubscribe(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4006 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4007 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4008 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4009
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4010
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4011 def test_subscriptions(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4012 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4013 Non-overridden subscriptions yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4014 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4015
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4016 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4017 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4018 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4019 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4020 self.assertEquals('retrieve-subscriptions',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4021 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4022
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4023 d = self.resource.subscriptions(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4024 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4025 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4026 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4027
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4028
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4029 def test_affiliations(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4030 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4031 Non-overridden affiliations yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4032 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4033
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4034 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4035 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4036 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4037 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4038 self.assertEquals('retrieve-affiliations',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4039 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4040
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4041 d = self.resource.affiliations(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4042 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4043 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4044 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4045
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4046
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4047 def test_create(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4048 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4049 Non-overridden create yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4050 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4051
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4052 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4053 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4054 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4055 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4056 self.assertEquals('create-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4057
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4058 d = self.resource.create(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4059 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4060 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4061 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4062
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4063
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4064 def test_default(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4065 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4066 Non-overridden default yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4067 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4068
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4069 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4070 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4071 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4072 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4073 self.assertEquals('retrieve-default',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4074 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4075
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4076 d = self.resource.default(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4077 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4078 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4079 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4080
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4081
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4082 def test_configureGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4083 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4084 Non-overridden configureGet yields unsupported
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4085 error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4086 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4087
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4088 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4089 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4090 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4091 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4092 self.assertEquals('config-node', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4093
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4094 d = self.resource.configureGet(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4095 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4096 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4097 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4098
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4099
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4100 def test_configureSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4101 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4102 Non-overridden configureSet yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4103 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4104
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4105 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4106 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4107 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4108 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4109 self.assertEquals('config-node', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4110
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4111 d = self.resource.configureSet(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4112 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4113 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4114 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4115
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4116
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4117 def test_items(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4118 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4119 Non-overridden items yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4120 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4121
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4122 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4123 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4124 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4125 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4126 self.assertEquals('retrieve-items', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4127
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4128 d = self.resource.items(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4129 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4130 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4131 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4132
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4133
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4134 def test_retract(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4135 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4136 Non-overridden retract yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4137 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4138
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4139 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4140 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4141 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4142 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4143 self.assertEquals('retract-items', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4144
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4145 d = self.resource.retract(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4146 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4147 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4148 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4149
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4150
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4151 def test_purge(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4152 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4153 Non-overridden purge yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4154 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4155
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4156 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4157 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4158 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4159 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4160 self.assertEquals('purge-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4161
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4162 d = self.resource.purge(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4163 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4164 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4165 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4166
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4167
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4168 def test_delete(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4169 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4170 Non-overridden delete yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4171 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4172
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4173 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4174 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4175 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4176 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4177 self.assertEquals('delete-nodes', result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4178
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4179 d = self.resource.delete(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4180 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4181 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4182 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4183
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4184
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4185 def test_affiliationsGet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4186 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4187 Non-overridden owner affiliations get yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4188 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4189
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4190 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4191 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4192 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4193 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4194 self.assertEquals('modify-affiliations',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4195 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4196
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4197 d = self.resource.affiliationsGet(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4198 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4199 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4200 return d
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4201
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4202
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4203 def test_affiliationsSet(self):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4204 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4205 Non-overridden owner affiliations set yields unsupported error.
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4206 """
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4207
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4208 def cb(result):
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4209 self.assertEquals('feature-not-implemented', result.condition)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4210 self.assertEquals('unsupported', result.appCondition.name)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4211 self.assertEquals(NS_PUBSUB_ERRORS, result.appCondition.uri)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4212 self.assertEquals('modify-affiliations',
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4213 result.appCondition['feature'])
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4214
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4215 d = self.resource.affiliationsSet(pubsub.PubSubRequest())
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4216 self.assertFailure(d, error.StanzaError)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4217 d.addCallback(cb)
2cd4f0ab9ad1 add tests for sat.tmp.wokkel
souliane <souliane@mailoo.org>
parents:
diff changeset
4218 return d