annotate idavoll/test/test_storage.py @ 142:812300cdbc22

Changed behaviour of retraction of items so that only the actually deleted item ids are returned, and no exception is raised for items that didn't actually exists.
author Ralph Meijer <ralphm@ik.nu>
date Tue, 12 Jul 2005 09:23:00 +0000
parents 8f6956b9a688
children f393bccec4bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
1 from twisted.trial import unittest
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
2 from twisted.trial.assertions import *
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
3 from twisted.words.protocols.jabber import jid
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
4 from twisted.internet import defer
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
5 from twisted.xish import domish
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
6
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
7 from idavoll import storage, pubsub
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
8
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
9 OWNER = jid.JID('owner@example.com')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
10 SUBSCRIBER = jid.JID('subscriber@example.com/Home')
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
11 SUBSCRIBER_NEW = jid.JID('new@example.com/Home')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
12 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
13 SUBSCRIBER_PENDING = jid.JID('pending@example.com/Home')
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
14 PUBLISHER = jid.JID('publisher@example.com')
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
15 ITEM = domish.Element((pubsub.NS_PUBSUB, 'item'), pubsub.NS_PUBSUB)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
16 ITEM['id'] = 'current'
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
17 ITEM.addElement(('testns', 'test'), content=u'Test \u2083 item')
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
18 ITEM_NEW = domish.Element((pubsub.NS_PUBSUB, 'item'), pubsub.NS_PUBSUB)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
19 ITEM_NEW['id'] = 'new'
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
20 ITEM_NEW.addElement(('testns', 'test'), content=u'Test \u2083 item')
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
21 ITEM_UPDATED = domish.Element((pubsub.NS_PUBSUB, 'item'), pubsub.NS_PUBSUB)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
22 ITEM_UPDATED['id'] = 'current'
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
23 ITEM_UPDATED.addElement(('testns', 'test'), content=u'Test \u2084 item')
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
24 ITEM_TO_BE_DELETED = domish.Element((pubsub.NS_PUBSUB, 'item'),
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
25 pubsub.NS_PUBSUB)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
26 ITEM_TO_BE_DELETED['id'] = 'to-be-deleted'
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
27 ITEM_TO_BE_DELETED.addElement(('testns', 'test'), content=u'Test \u2083 item')
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
28
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
29 def decode(object):
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
30 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
31 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
32 return object
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
33
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
34 class StorageTests:
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
35
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
36 def _assignTestNode(self, node):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
37 self.node = node
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
38
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
39 def setUpClass(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
40 d = self.s.get_node('pre-existing')
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
41 d.addCallback(self._assignTestNode)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
42 return d
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
43
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
44 def testGetNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
45 return self.s.get_node('pre-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
46
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
47 def testGetNonExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
48 d = self.s.get_node('non-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
49 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
50 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
51
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
52 def testGetNodeIDs(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
53 def cb(node_ids):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
54 assertIn('pre-existing', node_ids)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
55 assertNotIn('non-existing', node_ids)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
56
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
57 return self.s.get_node_ids().addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59 def testCreateExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
60 d = self.s.create_node('pre-existing', OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
61 assertFailure(d, storage.NodeExists)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
62 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
63
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
64 def testCreateNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
65 def cb(void):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
66 d = self.s.get_node('new 1')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
67 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
68
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
69 d = self.s.create_node('new 1', OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
70 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
71 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
72
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
73 def testDeleteNonExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
74 d = self.s.delete_node('non-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
75 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
76 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
77
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
78 def testDeleteNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
79 def cb(void):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
80 d = self.s.get_node('to-be-deleted')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
81 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
82 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
83
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
84 d = self.s.delete_node('to-be-deleted')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
85 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
86 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
87
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
88 def testGetAffiliations(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
89 def cb(affiliations):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
90 assertIn(('pre-existing', 'owner'), affiliations)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
91
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
92 d = self.s.get_affiliations(OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
93 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
94 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
95
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
96 def testGetSubscriptions(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
97 def cb(subscriptions):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
98 assertIn(('pre-existing', SUBSCRIBER, 'subscribed'), subscriptions)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
99
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
100 d = self.s.get_subscriptions(SUBSCRIBER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
101 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
102 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
103
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
104 # Node tests
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
105
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
106 def testGetType(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
107 assertEqual(self.node.get_type(), 'leaf')
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
108
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
109 def testGetConfiguration(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
110 config = self.node.get_configuration()
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
111 assertIn('pubsub#persist_items', config.iterkeys())
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
112 assertIn('pubsub#deliver_payloads', config.iterkeys())
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
113 assertEqual(config['pubsub#persist_items'], True)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
114 assertEqual(config['pubsub#deliver_payloads'], True)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
115
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
116 def testSetConfiguration(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
117 def get_config(node):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
118 d = node.set_configuration({'pubsub#persist_items': False})
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
119 d.addCallback(lambda _: node)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
120 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
121
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
122 def check_object_config(node):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
123 config = node.get_configuration()
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
124 assertEqual(config['pubsub#persist_items'], False)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
125
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
126 def get_node(void):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
127 return self.s.get_node('to-be-reconfigured')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
128
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
129 def check_storage_config(node):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
130 config = node.get_configuration()
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
131 assertEqual(config['pubsub#persist_items'], False)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
132
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
133 d = self.s.get_node('to-be-reconfigured')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
134 d.addCallback(get_config)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
135 d.addCallback(check_object_config)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
136 d.addCallback(get_node)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
137 d.addCallback(check_storage_config)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
138 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
139
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
140 def testGetMetaData(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
141 meta_data = self.node.get_meta_data()
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
142 for key, value in self.node.get_configuration().iteritems():
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
143 assertIn(key, meta_data.iterkeys())
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
144 assertEqual(value, meta_data[key])
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
145 assertIn('pubsub#node_type', meta_data.iterkeys())
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
146 assertEqual(meta_data['pubsub#node_type'], 'leaf')
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
147
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
148 def testGetAffiliation(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
149 def cb(affiliation):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
150 assertEqual(affiliation, 'owner')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
151
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
152 d = self.node.get_affiliation(OWNER)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
153 d.addCallback(cb)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
154 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
155
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
156 def testGetNonExistingAffiliation(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
157 def cb(affiliation):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
158 assertEqual(affiliation, None)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
159
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
160 d = self.node.get_affiliation(SUBSCRIBER)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
161 d.addCallback(cb)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
162 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
163
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
164 def testAddSubscription(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
165 def cb1(void):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
166 return self.node.get_subscription(SUBSCRIBER_NEW)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
167
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
168 def cb2(state):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
169 assertEqual(state, 'pending')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
170
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
171 d = self.node.add_subscription(SUBSCRIBER_NEW, 'pending')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
172 d.addCallback(cb1)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
173 d.addCallback(cb2)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
174 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
175
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
176 def testAddExistingSubscription(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
177 d = self.node.add_subscription(SUBSCRIBER, 'pending')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
178 assertFailure(d, storage.SubscriptionExists)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
179 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
180
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
181 def testGetSubscription(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
182 def cb(subscriptions):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
183 assertEquals(subscriptions[0][1], 'subscribed')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
184 assertEquals(subscriptions[1][1], 'pending')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
185 assertEquals(subscriptions[2][1], None)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
186
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
187 d = defer.DeferredList([self.node.get_subscription(SUBSCRIBER),
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
188 self.node.get_subscription(SUBSCRIBER_PENDING),
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
189 self.node.get_subscription(OWNER)])
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
190 d.addCallback(cb)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
191 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
192
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
193 def testRemoveSubscription(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
194 return self.node.remove_subscription(SUBSCRIBER_TO_BE_DELETED)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
195
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
196 def testRemoveNonExistingSubscription(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
197 d = self.node.remove_subscription(OWNER)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
198 assertFailure(d, storage.SubscriptionNotFound)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
199 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
200
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
201 def testGetSubscribers(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
202 def cb(subscribers):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
203 assertIn(SUBSCRIBER, subscribers)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
204 assertNotIn(SUBSCRIBER_PENDING, subscribers)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
205 assertNotIn(OWNER, subscribers)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
206
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
207 d = self.node.get_subscribers()
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
208 d.addCallback(cb)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
209 return d
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
210
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
211 def testIsSubscriber(self):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
212 def cb(subscribed):
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
213 assertEquals(subscribed[0][1], True)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
214 assertEquals(subscribed[1][1], False)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
215 assertEquals(subscribed[2][1], False)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
216
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
217 d = defer.DeferredList([self.node.is_subscribed(SUBSCRIBER),
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
218 self.node.is_subscribed(SUBSCRIBER_PENDING),
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
219 self.node.is_subscribed(OWNER)])
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
220 d.addCallback(cb)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
221 return d
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
222
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
223 def testStoreItems(self):
138
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
224 def cb1(void):
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
225 return self.node.get_items_by_id(['new'])
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
226
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
227 def cb2(result):
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
228 assertEqual(result[0], decode(ITEM_NEW.toXml()))
138
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
229
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
230 d = self.node.store_items([ITEM_NEW], PUBLISHER)
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
231 d.addCallback(cb1)
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
232 d.addCallback(cb2)
635e433810ef Actually test whether the item was indeed stored.
Ralph Meijer <ralphm@ik.nu>
parents: 137
diff changeset
233 return d
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
234
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
235 def testStoreUpdatedItems(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
236 def cb1(void):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
237 return self.node.get_items_by_id(['current'])
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
238
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
239 def cb2(result):
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
240 assertEqual(result[0], decode(ITEM_UPDATED.toXml()))
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
241
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
242 d = self.node.store_items([ITEM_UPDATED], PUBLISHER)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
243 d.addCallback(cb1)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
244 d.addCallback(cb2)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
245 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
246
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
247 def testRemoveItems(self):
142
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
248 def cb1(result):
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
249 assertEqual(result, ['to-be-deleted'])
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
250 return self.node.get_items_by_id(['to-be-deleted'])
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
251
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
252 def cb2(result):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
253 assertEqual(len(result), 0)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
254
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
255 d = self.node.remove_items(['to-be-deleted'])
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
256 d.addCallback(cb1)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
257 d.addCallback(cb2)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
258 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
259
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
260 def testRemoveNonExistingItems(self):
142
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
261 def cb(result):
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
262 assertEqual(result, [])
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
263
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
264 d = self.node.remove_items(['non-existing'])
812300cdbc22 Changed behaviour of retraction of items so that only the actually deleted
Ralph Meijer <ralphm@ik.nu>
parents: 139
diff changeset
265 d.addCallback(cb)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
266 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
267
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
268 def testGetItems(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
269 def cb(result):
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
270 assertIn(decode(ITEM.toXml()), result)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
271
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
272 d = self.node.get_items()
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
273 d.addCallback(cb)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
274 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
275
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
276 def testLastItem(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
277 def cb(result):
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
278 assertEqual([decode(ITEM.toXml())], result)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
279
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
280 d = self.node.get_items(1)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
281 d.addCallback(cb)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
282 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
283
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
284 def testGetItemsById(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
285 def cb(result):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
286 assertEqual(len(result), 1)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
287
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
288 d = self.node.get_items_by_id(['current'])
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
289 d.addCallback(cb)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
290 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
291
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
292 def testGetNonExistingItemsById(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
293 def cb(result):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
294 assertEqual(len(result), 0)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
295
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
296 d = self.node.get_items_by_id(['non-existing'])
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
297 d.addCallback(cb)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
298 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
299
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
300 def testPurge(self):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
301 def cb1(node):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
302 d = node.purge()
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
303 d.addCallback(lambda _: node)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
304 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
305
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
306 def cb2(node):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
307 return node.get_items()
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
308
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
309 def cb3(result):
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
310 assertEqual([], result)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
311
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
312 d = self.s.get_node('to-be-purged')
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
313 d.addCallback(cb1)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
314 d.addCallback(cb2)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
315 d.addCallback(cb3)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
316 return d
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
317
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
318 class MemoryStorageStorageTestCase(unittest.TestCase, StorageTests):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
319
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
320 def setUpClass(self):
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
321 from idavoll.memory_storage import Storage, LeafNode, Subscription, \
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
322 default_config
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
323 self.s = Storage()
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
324 self.s._nodes['pre-existing'] = \
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
325 LeafNode('pre-existing', OWNER, default_config)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
326 self.s._nodes['to-be-deleted'] = \
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
327 LeafNode('to-be-deleted', OWNER, None)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
328 self.s._nodes['to-be-reconfigured'] = \
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
329 LeafNode('to-be-reconfigured', OWNER, default_config)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
330 self.s._nodes['to-be-purged'] = \
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
331 LeafNode('to-be-purged', OWNER, None)
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
332
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
333 subscriptions = self.s._nodes['pre-existing']._subscriptions
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
334 subscriptions[SUBSCRIBER.full()] = Subscription('subscribed')
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
335 subscriptions[SUBSCRIBER_TO_BE_DELETED.full()] = \
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
336 Subscription('subscribed')
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
337 subscriptions[SUBSCRIBER_PENDING.full()] = \
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
338 Subscription('pending')
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
339
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
340 item = (decode(ITEM_TO_BE_DELETED.toXml()), PUBLISHER)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
341 self.s._nodes['pre-existing']._items['to-be-deleted'] = item
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
342 self.s._nodes['pre-existing']._itemlist.append(item)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
343 self.s._nodes['to-be-purged']._items['to-be-deleted'] = item
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
344 self.s._nodes['to-be-purged']._itemlist.append(item)
139
8f6956b9a688 Follow API change in Twisted Xish, while still being compatible with
Ralph Meijer <ralphm@ik.nu>
parents: 138
diff changeset
345 item = (decode(ITEM.toXml()), PUBLISHER)
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
346 self.s._nodes['pre-existing']._items['current'] = item
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
347 self.s._nodes['pre-existing']._itemlist.append(item)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
348
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
349 return StorageTests.setUpClass(self)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
350
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
351 class PgsqlStorageStorageTestCase(unittest.TestCase, StorageTests):
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
352 def _callSuperSetUpClass(self, void):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
353 return StorageTests.setUpClass(self)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
354
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
355 def setUpClass(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
356 from idavoll.pgsql_storage import Storage
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
357 self.s = Storage('ralphm', 'pubsub_test')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
358 self.s._dbpool.start()
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
359 d = self.s._dbpool.runInteraction(self.init)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
360 d.addCallback(self._callSuperSetUpClass)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
361 return d
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
362
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
363 def tearDownClass(self):
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
364 #return self.s._dbpool.runInteraction(self.cleandb)
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
365 pass
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
366
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
367 def init(self, cursor):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
368 self.cleandb(cursor)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
369 cursor.execute("""INSERT INTO nodes (node) VALUES ('pre-existing')""")
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
370 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
371 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-reconfigured')""")
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
372 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-purged')""")
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
373 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
374 OWNER.userhost())
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
375 cursor.execute("""INSERT INTO affiliations
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
376 (node_id, entity_id, affiliation)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
377 SELECT nodes.id, entities.id, 'owner'
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
378 FROM nodes, entities
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
379 WHERE node='pre-existing' AND jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
380 OWNER.userhost())
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
381 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
382 SUBSCRIBER.userhost())
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
383 cursor.execute("""INSERT INTO subscriptions
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
384 (node_id, entity_id, resource, subscription)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
385 SELECT nodes.id, entities.id, %s, 'subscribed'
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
386 FROM nodes, entities
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
387 WHERE node='pre-existing' AND jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
388 (SUBSCRIBER.resource,
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
389 SUBSCRIBER.userhost()))
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
390 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
391 SUBSCRIBER_TO_BE_DELETED.userhost())
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
392 cursor.execute("""INSERT INTO subscriptions
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
393 (node_id, entity_id, resource, subscription)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
394 SELECT nodes.id, entities.id, %s, 'subscribed'
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
395 FROM nodes, entities
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
396 WHERE node='pre-existing' AND jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
397 (SUBSCRIBER_TO_BE_DELETED.resource,
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
398 SUBSCRIBER_TO_BE_DELETED.userhost()))
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
399 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
400 SUBSCRIBER_PENDING.userhost())
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
401 cursor.execute("""INSERT INTO subscriptions
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
402 (node_id, entity_id, resource, subscription)
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
403 SELECT nodes.id, entities.id, %s, 'pending'
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
404 FROM nodes, entities
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
405 WHERE node='pre-existing' AND jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
406 (SUBSCRIBER_PENDING.resource,
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
407 SUBSCRIBER_PENDING.userhost()))
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
408 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
409 PUBLISHER.userhost())
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
410 cursor.execute("""INSERT INTO items
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
411 (node_id, publisher, item, data, date)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
412 SELECT nodes.id, %s, 'to-be-deleted', %s,
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
413 now() - interval '1 day'
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
414 FROM nodes
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
415 WHERE node='pre-existing'""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
416 (PUBLISHER.userhost(),
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
417 ITEM_TO_BE_DELETED.toXml()))
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
418 cursor.execute("""INSERT INTO items (node_id, publisher, item, data)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
419 SELECT nodes.id, %s, 'to-be-deleted', %s
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
420 FROM nodes
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
421 WHERE node='to-be-purged'""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
422 (PUBLISHER.userhost(),
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
423 ITEM_TO_BE_DELETED.toXml()))
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
424 cursor.execute("""INSERT INTO items (node_id, publisher, item, data)
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
425 SELECT nodes.id, %s, 'current', %s
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
426 FROM nodes
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
427 WHERE node='pre-existing'""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
428 (PUBLISHER.userhost(),
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
429 ITEM.toXml()))
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
430
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
431 def cleandb(self, cursor):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
432 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
433 ('non-existing', 'pre-existing', 'to-be-deleted',
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
434 'new 1', 'new 2', 'new 3', 'to-be-reconfigured',
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
435 'to-be-purged')""")
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
436 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
437 OWNER.userhost())
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
438 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
439 SUBSCRIBER.userhost())
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
440 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
441 SUBSCRIBER_TO_BE_DELETED.userhost())
123
8f99b4f7aea2 Add tests for all Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 117
diff changeset
442 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
443 SUBSCRIBER_PENDING.userhost())
131
fe8cb99363ff Add test cases for LeafNodes.
Ralph Meijer <ralphm@ik.nu>
parents: 123
diff changeset
444 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
137
aca904a41a43 Discover client_encoding parameter to pyPgSQL.
Ralph Meijer <ralphm@ik.nu>
parents: 131
diff changeset
445 PUBLISHER.userhost())