Mercurial > libervia-pubsub
annotate src/test/test_storage.py @ 396:562e7a01218d
backend: fixed getOwnerRoster call in _prepareNotify
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 23 Feb 2019 21:00:29 +0100 |
parents | aa3a464df605 |
children |
rev | line source |
---|---|
233 | 1 #!/usr/bin/python |
2 #-*- coding: utf-8 -*- | |
3 | |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
4 # Copyright (c) 2003-2011 Ralph Meijer |
384 | 5 # Copyright (c) 2012-2019 Jérôme Poisson |
233 | 6 |
7 | |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
11 # (at your option) any later version. |
233 | 12 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
16 # GNU Affero General Public License for more details. |
233 | 17 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
20 # -- |
233 | 21 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
22 # This program is based on Idavoll (http://idavoll.ik.nu/), |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
23 # originaly written by Ralph Meijer (http://ralphm.net/blog/) |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
24 # It is sublicensed under AGPL v3 (or any later version) as allowed by the original |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
25 # license. |
233 | 26 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
27 # -- |
233 | 28 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
29 # Here is a copy of the original license: |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
30 |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
31 # Copyright (c) 2003-2011 Ralph Meijer |
233 | 32 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
33 # Permission is hereby granted, free of charge, to any person obtaining |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
34 # a copy of this software and associated documentation files (the |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
35 # "Software"), to deal in the Software without restriction, including |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
36 # without limitation the rights to use, copy, modify, merge, publish, |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
37 # distribute, sublicense, and/or sell copies of the Software, and to |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
38 # permit persons to whom the Software is furnished to do so, subject to |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
39 # the following conditions: |
233 | 40 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
41 # The above copyright notice and this permission notice shall be |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
42 # included in all copies or substantial portions of the Software. |
233 | 43 |
312
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
44 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
45 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
46 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
47 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
48 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
49 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
5d7c3787672e
fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents:
311
diff
changeset
|
50 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
233 | 51 |
155
5191ba7c4df8
Work towards first release 0.5.0.
Ralph Meijer <ralphm@ik.nu>
parents:
146
diff
changeset
|
52 |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
53 """ |
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
54 Tests for L{idavoll.memory_storage} and L{idavoll.pgsql_storage}. |
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
55 """ |
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
56 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
57 from zope.interface.verify import verifyObject |
114 | 58 from twisted.trial import unittest |
59 from twisted.words.protocols.jabber import jid | |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
60 from twisted.internet import defer |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
61 from twisted.words.xish import domish |
114 | 62 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
63 from sat_pubsub import error, iidavoll, const |
114 | 64 |
226
b7018ec56ee5
Always use the bare JID for affilitations.
Ralph Meijer <ralphm@ik.nu>
parents:
223
diff
changeset
|
65 OWNER = jid.JID('owner@example.com/Work') |
114 | 66 SUBSCRIBER = jid.JID('subscriber@example.com/Home') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
67 SUBSCRIBER_NEW = jid.JID('new@example.com/Home') |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
68 SUBSCRIBER_TO_BE_DELETED = jid.JID('to_be_deleted@example.com/Home') |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
69 SUBSCRIBER_PENDING = jid.JID('pending@example.com/Home') |
131 | 70 PUBLISHER = jid.JID('publisher@example.com') |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
71 ITEM = domish.Element((None, 'item')) |
131 | 72 ITEM['id'] = 'current' |
73 ITEM.addElement(('testns', 'test'), content=u'Test \u2083 item') | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
74 ITEM_NEW = domish.Element((None, 'item')) |
131 | 75 ITEM_NEW['id'] = 'new' |
76 ITEM_NEW.addElement(('testns', 'test'), content=u'Test \u2083 item') | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
77 ITEM_UPDATED = domish.Element((None, 'item')) |
131 | 78 ITEM_UPDATED['id'] = 'current' |
79 ITEM_UPDATED.addElement(('testns', 'test'), content=u'Test \u2084 item') | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
80 ITEM_TO_BE_DELETED = domish.Element((None, 'item')) |
131 | 81 ITEM_TO_BE_DELETED['id'] = 'to-be-deleted' |
82 ITEM_TO_BE_DELETED.addElement(('testns', 'test'), content=u'Test \u2083 item') | |
114 | 83 |
139
8f6956b9a688
Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents:
138
diff
changeset
|
84 def decode(object): |
8f6956b9a688
Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents:
138
diff
changeset
|
85 if isinstance(object, str): |
8f6956b9a688
Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents:
138
diff
changeset
|
86 object = object.decode('utf-8') |
8f6956b9a688
Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents:
138
diff
changeset
|
87 return object |
8f6956b9a688
Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents:
138
diff
changeset
|
88 |
171
bc269696ef42
Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents:
167
diff
changeset
|
89 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
90 |
114 | 91 class StorageTests: |
92 | |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
93 def _assignTestNode(self, node): |
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
94 self.node = node |
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
95 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
96 |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
97 def setUp(self): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
98 d = self.s.getNode('pre-existing') |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
99 d.addCallback(self._assignTestNode) |
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
100 return d |
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
101 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
102 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
103 def test_interfaceIStorage(self): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
104 self.assertTrue(verifyObject(iidavoll.IStorage, self.s)) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
105 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
106 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
107 def test_interfaceINode(self): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
108 self.assertTrue(verifyObject(iidavoll.INode, self.node)) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
109 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
110 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
111 def test_interfaceILeafNode(self): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
112 self.assertTrue(verifyObject(iidavoll.ILeafNode, self.node)) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
113 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
114 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
115 def test_getNode(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
116 return self.s.getNode('pre-existing') |
114 | 117 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
118 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
119 def test_getNonExistingNode(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
120 d = self.s.getNode('non-existing') |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
121 self.assertFailure(d, error.NodeNotFound) |
114 | 122 return d |
123 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
124 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
125 def test_getNodeIDs(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
126 def cb(nodeIdentifiers): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
127 self.assertIn('pre-existing', nodeIdentifiers) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
128 self.assertNotIn('non-existing', nodeIdentifiers) |
114 | 129 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
130 return self.s.getNodeIds().addCallback(cb) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
131 |
114 | 132 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
133 def test_createExistingNode(self): |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
134 config = self.s.getDefaultConfiguration('leaf') |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
135 config['pubsub#node_type'] = 'leaf' |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
136 d = self.s.createNode('pre-existing', OWNER, config) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
137 self.assertFailure(d, error.NodeExists) |
114 | 138 return d |
139 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
140 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
141 def test_createNode(self): |
114 | 142 def cb(void): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
143 d = self.s.getNode('new 1') |
114 | 144 return d |
145 | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
146 config = self.s.getDefaultConfiguration('leaf') |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
147 config['pubsub#node_type'] = 'leaf' |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
148 d = self.s.createNode('new 1', OWNER, config) |
114 | 149 d.addCallback(cb) |
150 return d | |
151 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
152 |
221
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
153 def test_createNodeChangingConfig(self): |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
154 """ |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
155 The configuration passed to createNode must be free to be changed. |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
156 """ |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
157 def cb(result): |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
158 node1, node2 = result |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
159 self.assertTrue(node1.getConfiguration()['pubsub#persist_items']) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
160 |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
161 config = { |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
162 "pubsub#persist_items": True, |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
163 "pubsub#deliver_payloads": True, |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
164 "pubsub#send_last_published_item": 'on_sub', |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
165 "pubsub#node_type": 'leaf', |
240
70c8bb90d75f
added access_model to config, default to 'open'
Goffi <goffi@goffi.org>
parents:
235
diff
changeset
|
166 "pubsub#access_model": 'open', |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
167 const.OPT_PUBLISH_MODEL: const.VAL_PMODEL_OPEN |
221
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
168 } |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
169 |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
170 def unsetPersistItems(_): |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
171 config["pubsub#persist_items"] = False |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
172 |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
173 d = defer.succeed(None) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
174 d.addCallback(lambda _: self.s.createNode('new 1', OWNER, config)) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
175 d.addCallback(unsetPersistItems) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
176 d.addCallback(lambda _: self.s.createNode('new 2', OWNER, config)) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
177 d.addCallback(lambda _: defer.gatherResults([ |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
178 self.s.getNode('new 1'), |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
179 self.s.getNode('new 2')])) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
180 d.addCallback(cb) |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
181 return d |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
182 |
a430976f2977
Make a copy of the config to prevent later modification.
Ralph Meijer <ralphm@ik.nu>
parents:
219
diff
changeset
|
183 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
184 def test_deleteNonExistingNode(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
185 d = self.s.deleteNode('non-existing') |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
186 self.assertFailure(d, error.NodeNotFound) |
114 | 187 return d |
188 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
189 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
190 def test_deleteNode(self): |
114 | 191 def cb(void): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
192 d = self.s.getNode('to-be-deleted') |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
193 self.assertFailure(d, error.NodeNotFound) |
114 | 194 return d |
195 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
196 d = self.s.deleteNode('to-be-deleted') |
114 | 197 d.addCallback(cb) |
198 return d | |
199 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
200 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
201 def test_getAffiliations(self): |
114 | 202 def cb(affiliations): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
203 self.assertIn(('pre-existing', 'owner'), affiliations) |
114 | 204 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
205 d = self.s.getAffiliations(OWNER) |
114 | 206 d.addCallback(cb) |
207 return d | |
208 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
209 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
210 def test_getSubscriptions(self): |
114 | 211 def cb(subscriptions): |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
212 found = False |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
213 for subscription in subscriptions: |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
214 if (subscription.nodeIdentifier == 'pre-existing' and |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
215 subscription.subscriber == SUBSCRIBER and |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
216 subscription.state == 'subscribed'): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
217 found = True |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
218 self.assertTrue(found) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
219 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
220 d = self.s.getSubscriptions(SUBSCRIBER) |
114 | 221 d.addCallback(cb) |
222 return d | |
223 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
224 |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
225 # Node tests |
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
226 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
227 def test_getType(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
228 self.assertEqual(self.node.getType(), 'leaf') |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
229 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
230 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
231 def test_getConfiguration(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
232 config = self.node.getConfiguration() |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
233 self.assertIn('pubsub#persist_items', config.iterkeys()) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
234 self.assertIn('pubsub#deliver_payloads', config.iterkeys()) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
235 self.assertEqual(config['pubsub#persist_items'], True) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
236 self.assertEqual(config['pubsub#deliver_payloads'], True) |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
237 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
238 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
239 def test_setConfiguration(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
240 def getConfig(node): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
241 d = node.setConfiguration({'pubsub#persist_items': False}) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
242 d.addCallback(lambda _: node) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
243 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
244 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
245 def checkObjectConfig(node): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
246 config = node.getConfiguration() |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
247 self.assertEqual(config['pubsub#persist_items'], False) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
248 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
249 def getNode(void): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
250 return self.s.getNode('to-be-reconfigured') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
251 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
252 def checkStorageConfig(node): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
253 config = node.getConfiguration() |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
254 self.assertEqual(config['pubsub#persist_items'], False) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
255 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
256 d = self.s.getNode('to-be-reconfigured') |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
257 d.addCallback(getConfig) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
258 d.addCallback(checkObjectConfig) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
259 d.addCallback(getNode) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
260 d.addCallback(checkStorageConfig) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
261 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
262 |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
263 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
264 def test_getMetaData(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
265 metaData = self.node.getMetaData() |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
266 for key, value in self.node.getConfiguration().iteritems(): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
267 self.assertIn(key, metaData.iterkeys()) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
268 self.assertEqual(value, metaData[key]) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
269 self.assertIn('pubsub#node_type', metaData.iterkeys()) |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
270 self.assertEqual(metaData['pubsub#node_type'], 'leaf') |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
271 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
272 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
273 def test_getAffiliation(self): |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
274 def cb(affiliation): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
275 self.assertEqual(affiliation, 'owner') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
276 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
277 d = self.node.getAffiliation(OWNER) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
278 d.addCallback(cb) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
279 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
280 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
281 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
282 def test_getNonExistingAffiliation(self): |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
283 def cb(affiliation): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
284 self.assertEqual(affiliation, None) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
285 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
286 d = self.node.getAffiliation(SUBSCRIBER) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
287 d.addCallback(cb) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
288 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
289 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
290 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
291 def test_addSubscription(self): |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
292 def cb1(void): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
293 return self.node.getSubscription(SUBSCRIBER_NEW) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
294 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
295 def cb2(subscription): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
296 self.assertEqual(subscription.state, 'pending') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
297 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
298 d = self.node.addSubscription(SUBSCRIBER_NEW, 'pending', {}) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
299 d.addCallback(cb1) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
300 d.addCallback(cb2) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
301 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
302 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
303 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
304 def test_addExistingSubscription(self): |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
305 d = self.node.addSubscription(SUBSCRIBER, 'pending', {}) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
306 self.assertFailure(d, error.SubscriptionExists) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
307 return d |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
308 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
309 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
310 def test_getSubscription(self): |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
311 def cb(subscriptions): |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
312 self.assertEquals(subscriptions[0].state, 'subscribed') |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
313 self.assertEquals(subscriptions[1].state, 'pending') |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
314 self.assertEquals(subscriptions[2], None) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
315 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
316 d = defer.gatherResults([self.node.getSubscription(SUBSCRIBER), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
317 self.node.getSubscription(SUBSCRIBER_PENDING), |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
318 self.node.getSubscription(OWNER)]) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
319 d.addCallback(cb) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
320 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
321 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
322 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
323 def test_removeSubscription(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
324 return self.node.removeSubscription(SUBSCRIBER_TO_BE_DELETED) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
325 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
326 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
327 def test_removeNonExistingSubscription(self): |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
328 d = self.node.removeSubscription(OWNER) |
171
bc269696ef42
Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents:
167
diff
changeset
|
329 self.assertFailure(d, error.NotSubscribed) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
330 return d |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
331 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
332 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
333 def test_getNodeSubscriptions(self): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
334 def extractSubscribers(subscriptions): |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
335 return [subscription.subscriber for subscription in subscriptions] |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
336 |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
337 def cb(subscribers): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
338 self.assertIn(SUBSCRIBER, subscribers) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
339 self.assertNotIn(SUBSCRIBER_PENDING, subscribers) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
340 self.assertNotIn(OWNER, subscribers) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
341 |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
342 d = self.node.getSubscriptions('subscribed') |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
343 d.addCallback(extractSubscribers) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
344 d.addCallback(cb) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
345 return d |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
346 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
347 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
348 def test_isSubscriber(self): |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
349 def cb(subscribed): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
350 self.assertEquals(subscribed[0][1], True) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
351 self.assertEquals(subscribed[1][1], True) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
352 self.assertEquals(subscribed[2][1], False) |
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
353 self.assertEquals(subscribed[3][1], False) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
354 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
355 d = defer.DeferredList([self.node.isSubscribed(SUBSCRIBER), |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
356 self.node.isSubscribed(SUBSCRIBER.userhostJID()), |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
357 self.node.isSubscribed(SUBSCRIBER_PENDING), |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
358 self.node.isSubscribed(OWNER)]) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
359 d.addCallback(cb) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
360 return d |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
361 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
362 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
363 def test_storeItems(self): |
138
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
364 def cb1(void): |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
365 return self.node.getItemsById("", False, ['new']) |
138
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
366 |
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
367 def cb2(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
368 self.assertEqual(ITEM_NEW.toXml(), result[0].toXml()) |
138
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
369 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
370 d = self.node.storeItems([(const.VAL_AMODEL_DEFAULT, {}, ITEM_NEW)], PUBLISHER) |
138
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
371 d.addCallback(cb1) |
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
372 d.addCallback(cb2) |
635e433810ef
Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents:
137
diff
changeset
|
373 return d |
131 | 374 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
375 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
376 def test_storeUpdatedItems(self): |
131 | 377 def cb1(void): |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
378 return self.node.getItemsById("", False, ['current']) |
131 | 379 |
380 def cb2(result): | |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
381 self.assertEqual(ITEM_UPDATED.toXml(), result[0].toXml()) |
131 | 382 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
383 d = self.node.storeItems([(const.VAL_AMODEL_DEFAULT, {}, ITEM_UPDATED)], PUBLISHER) |
131 | 384 d.addCallback(cb1) |
385 d.addCallback(cb2) | |
386 return d | |
387 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
388 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
389 def test_removeItems(self): |
142
812300cdbc22
Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents:
139
diff
changeset
|
390 def cb1(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
391 self.assertEqual(['to-be-deleted'], result) |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
392 return self.node.getItemsById("", False, ['to-be-deleted']) |
131 | 393 |
394 def cb2(result): | |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
395 self.assertEqual(0, len(result)) |
131 | 396 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
397 d = self.node.removeItems(['to-be-deleted']) |
131 | 398 d.addCallback(cb1) |
399 d.addCallback(cb2) | |
400 return d | |
401 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
402 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
403 def test_removeNonExistingItems(self): |
142
812300cdbc22
Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents:
139
diff
changeset
|
404 def cb(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
405 self.assertEqual([], result) |
142
812300cdbc22
Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents:
139
diff
changeset
|
406 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
407 d = self.node.removeItems(['non-existing']) |
142
812300cdbc22
Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents:
139
diff
changeset
|
408 d.addCallback(cb) |
131 | 409 return d |
410 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
411 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
412 def test_getItems(self): |
131 | 413 def cb(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
414 items = [item.toXml() for item in result] |
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
415 self.assertIn(ITEM.toXml(), items) |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
416 d = self.node.getItems("", False) |
131 | 417 d.addCallback(cb) |
418 return d | |
419 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
420 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
421 def test_lastItem(self): |
131 | 422 def cb(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
423 self.assertEqual(1, len(result)) |
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
424 self.assertEqual(ITEM.toXml(), result[0].toXml()) |
131 | 425 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
426 d = self.node.getItems("", False, 1) |
131 | 427 d.addCallback(cb) |
428 return d | |
429 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
430 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
431 def test_getItemsById(self): |
131 | 432 def cb(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
433 self.assertEqual(1, len(result)) |
131 | 434 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
435 d = self.node.getItemsById("", False, ['current']) |
131 | 436 d.addCallback(cb) |
437 return d | |
438 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
439 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
440 def test_getNonExistingItemsById(self): |
131 | 441 def cb(result): |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
442 self.assertEqual(0, len(result)) |
131 | 443 |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
444 d = self.node.getItemsById("", False, ['non-existing']) |
131 | 445 d.addCallback(cb) |
446 return d | |
447 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
448 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
449 def test_purge(self): |
131 | 450 def cb1(node): |
451 d = node.purge() | |
452 d.addCallback(lambda _: node) | |
453 return d | |
454 | |
455 def cb2(node): | |
266
560b6cdc50b2
fix the backend and storage tests
souliane <souliane@mailoo.org>
parents:
255
diff
changeset
|
456 return node.getItems("", False) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
457 |
131 | 458 def cb3(result): |
157
21fcfb86433f
Fix tests to work with current Twisted. Really do 0.5.0 release.
Ralph Meijer <ralphm@ik.nu>
parents:
155
diff
changeset
|
459 self.assertEqual([], result) |
131 | 460 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
461 d = self.s.getNode('to-be-purged') |
131 | 462 d.addCallback(cb1) |
463 d.addCallback(cb2) | |
464 d.addCallback(cb3) | |
465 return d | |
466 | |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
467 |
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
468 def test_getNodeAffilatiations(self): |
145
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
469 def cb1(node): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
470 return node.getAffiliations() |
145
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
471 |
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
472 def cb2(affiliations): |
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
473 affiliations = dict(((a[0].full(), a[1]) for a in affiliations)) |
226
b7018ec56ee5
Always use the bare JID for affilitations.
Ralph Meijer <ralphm@ik.nu>
parents:
223
diff
changeset
|
474 self.assertEquals(affiliations[OWNER.userhost()], 'owner') |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
475 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
476 d = self.s.getNode('pre-existing') |
145
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
477 d.addCallback(cb1) |
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
478 d.addCallback(cb2) |
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
479 return d |
f393bccec4bc
Add get_affiliations to Node class in storage facilities in preparation of
Ralph Meijer <ralphm@ik.nu>
parents:
142
diff
changeset
|
480 |
171
bc269696ef42
Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents:
167
diff
changeset
|
481 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
482 |
114 | 483 class MemoryStorageStorageTestCase(unittest.TestCase, StorageTests): |
484 | |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
485 def setUp(self): |
234
51af2ed8bd50
replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents:
233
diff
changeset
|
486 from sat_pubsub.memory_storage import Storage, PublishedItem, LeafNode |
51af2ed8bd50
replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents:
233
diff
changeset
|
487 from sat_pubsub.memory_storage import Subscription |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
488 |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
489 defaultConfig = Storage.defaultConfig['leaf'] |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
490 |
114 | 491 self.s = Storage() |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
492 self.s._nodes['pre-existing'] = \ |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
493 LeafNode('pre-existing', OWNER, defaultConfig) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
494 self.s._nodes['to-be-deleted'] = \ |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
495 LeafNode('to-be-deleted', OWNER, None) |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
496 self.s._nodes['to-be-reconfigured'] = \ |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
497 LeafNode('to-be-reconfigured', OWNER, defaultConfig) |
131 | 498 self.s._nodes['to-be-purged'] = \ |
499 LeafNode('to-be-purged', OWNER, None) | |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
500 |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
501 subscriptions = self.s._nodes['pre-existing']._subscriptions |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
502 subscriptions[SUBSCRIBER.full()] = Subscription('pre-existing', |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
503 SUBSCRIBER, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
504 'subscribed') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
505 subscriptions[SUBSCRIBER_TO_BE_DELETED.full()] = \ |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
506 Subscription('pre-existing', SUBSCRIBER_TO_BE_DELETED, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
507 'subscribed') |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
508 subscriptions[SUBSCRIBER_PENDING.full()] = \ |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
509 Subscription('pre-existing', SUBSCRIBER_PENDING, |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
510 'pending') |
114 | 511 |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
512 item = PublishedItem(ITEM_TO_BE_DELETED, PUBLISHER) |
131 | 513 self.s._nodes['pre-existing']._items['to-be-deleted'] = item |
514 self.s._nodes['pre-existing']._itemlist.append(item) | |
515 self.s._nodes['to-be-purged']._items['to-be-deleted'] = item | |
516 self.s._nodes['to-be-purged']._itemlist.append(item) | |
202
77c61e2b8c75
Use `domish.Element`s to represent items, instead of serialized XML.
Ralph Meijer <ralphm@ik.nu>
parents:
198
diff
changeset
|
517 item = PublishedItem(ITEM, PUBLISHER) |
131 | 518 self.s._nodes['pre-existing']._items['current'] = item |
519 self.s._nodes['pre-existing']._itemlist.append(item) | |
520 | |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
521 return StorageTests.setUp(self) |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
522 |
171
bc269696ef42
Reply with the correct error condition on subscription when not subscribed.
Ralph Meijer <ralphm@ik.nu>
parents:
167
diff
changeset
|
523 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
524 |
114 | 525 class PgsqlStorageStorageTestCase(unittest.TestCase, StorageTests): |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
526 |
219
bb7103da9879
Make the PostgreSQL ConnectionPool only once for all unit tests.
Ralph Meijer <ralphm@ik.nu>
parents:
206
diff
changeset
|
527 dbpool = None |
bb7103da9879
Make the PostgreSQL ConnectionPool only once for all unit tests.
Ralph Meijer <ralphm@ik.nu>
parents:
206
diff
changeset
|
528 |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
529 def setUp(self): |
234
51af2ed8bd50
replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents:
233
diff
changeset
|
530 from sat_pubsub.pgsql_storage import Storage |
204
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
531 from twisted.enterprise import adbapi |
219
bb7103da9879
Make the PostgreSQL ConnectionPool only once for all unit tests.
Ralph Meijer <ralphm@ik.nu>
parents:
206
diff
changeset
|
532 if self.dbpool is None: |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
533 self.__class__.dbpool = adbapi.ConnectionPool('psycopg2', |
204
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
534 database='pubsub_test', |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
535 cp_reconnect=True, |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
536 client_encoding='utf-8', |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
537 connection_factory=NamedTupleConnection, |
204
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
538 ) |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
539 self.s = Storage(self.dbpool) |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
540 self.dbpool.start() |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
541 d = self.dbpool.runInteraction(self.init) |
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
542 d.addCallback(lambda _: StorageTests.setUp(self)) |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
543 return d |
114 | 544 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
545 |
204
b4bf0a5ce50d
Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents:
202
diff
changeset
|
546 def tearDown(self): |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
547 d = self.dbpool.runInteraction(self.cleandb) |
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
548 return d.addCallback(lambda _: self.dbpool.close()) |
114 | 549 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
550 |
114 | 551 def init(self, cursor): |
552 self.cleandb(cursor) | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
553 cursor.execute("""INSERT INTO nodes |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
554 (node, node_type, persist_items) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
555 VALUES ('pre-existing', 'leaf', TRUE)""") |
114 | 556 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-deleted')""") |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
557 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-reconfigured')""") |
131 | 558 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-purged')""") |
114 | 559 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
560 (OWNER.userhost(),)) |
114 | 561 cursor.execute("""INSERT INTO affiliations |
562 (node_id, entity_id, affiliation) | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
563 SELECT node_id, entity_id, 'owner' |
114 | 564 FROM nodes, entities |
565 WHERE node='pre-existing' AND jid=%s""", | |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
566 (OWNER.userhost(),)) |
114 | 567 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
568 (SUBSCRIBER.userhost(),)) |
114 | 569 cursor.execute("""INSERT INTO subscriptions |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
570 (node_id, entity_id, resource, state) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
571 SELECT node_id, entity_id, %s, 'subscribed' |
114 | 572 FROM nodes, entities |
573 WHERE node='pre-existing' AND jid=%s""", | |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
574 (SUBSCRIBER.resource, |
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
575 SUBSCRIBER.userhost())) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
576 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
577 (SUBSCRIBER_TO_BE_DELETED.userhost(),)) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
578 cursor.execute("""INSERT INTO subscriptions |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
579 (node_id, entity_id, resource, state) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
580 SELECT node_id, entity_id, %s, 'subscribed' |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
581 FROM nodes, entities |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
582 WHERE node='pre-existing' AND jid=%s""", |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
583 (SUBSCRIBER_TO_BE_DELETED.resource, |
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
584 SUBSCRIBER_TO_BE_DELETED.userhost())) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
585 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
586 (SUBSCRIBER_PENDING.userhost(),)) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
587 cursor.execute("""INSERT INTO subscriptions |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
588 (node_id, entity_id, resource, state) |
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
589 SELECT node_id, entity_id, %s, 'pending' |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
590 FROM nodes, entities |
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
591 WHERE node='pre-existing' AND jid=%s""", |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
592 (SUBSCRIBER_PENDING.resource, |
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
593 SUBSCRIBER_PENDING.userhost())) |
131 | 594 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
595 (PUBLISHER.userhost(),)) |
131 | 596 cursor.execute("""INSERT INTO items |
367
a772f7dac930
backend, storage(pgsql): creation/update date + serial ids:
Goffi <goffi@goffi.org>
parents:
365
diff
changeset
|
597 (node_id, publisher, item, data, created) |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
598 SELECT node_id, %s, 'to-be-deleted', %s, |
131 | 599 now() - interval '1 day' |
600 FROM nodes | |
601 WHERE node='pre-existing'""", | |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
602 (PUBLISHER.userhost(), |
131 | 603 ITEM_TO_BE_DELETED.toXml())) |
604 cursor.execute("""INSERT INTO items (node_id, publisher, item, data) | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
605 SELECT node_id, %s, 'to-be-deleted', %s |
131 | 606 FROM nodes |
607 WHERE node='to-be-purged'""", | |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
608 (PUBLISHER.userhost(), |
131 | 609 ITEM_TO_BE_DELETED.toXml())) |
610 cursor.execute("""INSERT INTO items (node_id, publisher, item, data) | |
206
274a45d2a5ab
Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents:
204
diff
changeset
|
611 SELECT node_id, %s, 'current', %s |
131 | 612 FROM nodes |
613 WHERE node='pre-existing'""", | |
137
aca904a41a43
Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents:
131
diff
changeset
|
614 (PUBLISHER.userhost(), |
131 | 615 ITEM.toXml())) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
616 |
198
e404775b12df
Change naming and spacing conventions to match Twisted's.
Ralph Meijer <ralphm@ik.nu>
parents:
171
diff
changeset
|
617 |
114 | 618 def cleandb(self, cursor): |
619 cursor.execute("""DELETE FROM nodes WHERE node in | |
117
bc872c33e88c
Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
114
diff
changeset
|
620 ('non-existing', 'pre-existing', 'to-be-deleted', |
131 | 621 'new 1', 'new 2', 'new 3', 'to-be-reconfigured', |
622 'to-be-purged')""") | |
114 | 623 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
624 (OWNER.userhost(),)) |
114 | 625 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
626 (SUBSCRIBER.userhost(),)) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
627 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
628 (SUBSCRIBER_NEW.userhost(),)) |
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
629 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
630 (SUBSCRIBER_TO_BE_DELETED.userhost(),)) |
123
8f99b4f7aea2
Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents:
117
diff
changeset
|
631 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
632 (SUBSCRIBER_PENDING.userhost(),)) |
131 | 633 cursor.execute("""DELETE FROM entities WHERE jid=%s""", |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
634 (PUBLISHER.userhost(),)) |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
635 |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
636 |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
637 try: |
227
8540825f85e0
Replaced unmaintained pyPgSQL by Psycopg 2
Goffi <goffi@goffi.org>
parents:
226
diff
changeset
|
638 import psycopg2 |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
639 psycopg2 |
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
640 from psycopg2.extras import NamedTupleConnection |
167
ef22e4150caa
Move protocol implementations (pubsub, disco, forms) to and depend on wokkel.
Ralph Meijer <ralphm@ik.nu>
parents:
157
diff
changeset
|
641 except ImportError: |
276
b757c29b20d7
import changes from idavoll changeset 233 (24be3a11ddbc), by Ralph Meijer and based on a patch by Nuno Santos
souliane <souliane@mailoo.org>
parents:
266
diff
changeset
|
642 PgsqlStorageStorageTestCase.skip = "psycopg2 not available" |