annotate idavoll/test/test_storage.py @ 119:3e7a7426f518

Added SubscriptionNotFound and SubscriptionExists errors. Added documentation to INode.
author Ralph Meijer <ralphm@ik.nu>
date Tue, 12 Apr 2005 12:16:54 +0000
parents bc872c33e88c
children 8f99b4f7aea2
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
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
4
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
5 from idavoll import storage
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
6
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
7 OWNER = jid.JID('owner@example.com')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
8 SUBSCRIBER = jid.JID('subscriber@example.com/Home')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
9
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
10 class StorageTests:
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
11
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
12 def _assignTestNode(self, node):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
13 self.node = node
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
14
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
15 def setUpClass(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
16 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
17 d.addCallback(self._assignTestNode)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
18 return d
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
19
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
20 def testGetNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
21 return self.s.get_node('pre-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
22
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
23 def testGetNonExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
24 d = self.s.get_node('non-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
25 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
26 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
27
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
28 def testGetNodeIDs(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
29 def cb(node_ids):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
30 assertIn('pre-existing', node_ids)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
31 assertNotIn('non-existing', node_ids)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
32
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
33 return self.s.get_node_ids().addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
34
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
35 def testCreateExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
36 d = self.s.create_node('pre-existing', OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
37 assertFailure(d, storage.NodeExists)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
38 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
39
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
40 def testCreateNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
41 def cb(void):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
42 d = self.s.get_node('new 1')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
43 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
44
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
45 d = self.s.create_node('new 1', OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
46 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
47 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
48
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
49 def testDeleteNonExistingNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
50 d = self.s.delete_node('non-existing')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
51 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
52 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
53
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
54 def testDeleteNode(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
55 def cb(void):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
56 d = self.s.get_node('to-be-deleted')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
57 assertFailure(d, storage.NodeNotFound)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
60 d = self.s.delete_node('to-be-deleted')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
61 d.addCallback(cb)
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 testGetAffiliations(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
65 def cb(affiliations):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
66 assertIn(('pre-existing', 'owner'), affiliations)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
67
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
68 d = self.s.get_affiliations(OWNER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
69 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
70 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
71
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
72 def testGetSubscriptions(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
73 def cb(subscriptions):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
74 assertIn(('pre-existing', SUBSCRIBER, 'subscribed'), subscriptions)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
75
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
76 d = self.s.get_subscriptions(SUBSCRIBER)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
77 d.addCallback(cb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
78 return d
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
79
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
80 # Node tests
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
81
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
82 def testGetType(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
83 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
84
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
85 def testGetConfiguration(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
86 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
87 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
88 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
89 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
90 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
91
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
92 def testGetMetaData(self):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
100
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
101 class MemoryStorageStorageTestCase(unittest.TestCase, StorageTests):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
102
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
103 def setUpClass(self):
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
104 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
105 default_config
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
106 self.s = Storage()
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
107 self.s._nodes['pre-existing'] = LeafNode('pre-existing', OWNER,
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
108 default_config)
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
109 self.s._nodes['to-be-deleted'] = LeafNode('to-be-deleted', OWNER, None)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
110 self.s._nodes['pre-existing']._subscriptions[SUBSCRIBER.full()] = \
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
111 Subscription('subscribed')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
112
117
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
113 return StorageTests.setUpClass(self)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
114
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
115 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
116 def _callSuperSetUpClass(self, void):
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
117 return StorageTests.setUpClass(self)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
118
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
119 def setUpClass(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
120 from idavoll.pgsql_storage import Storage
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
121 self.s = Storage('ralphm', 'pubsub_test')
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
122 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
123 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
124 d.addCallback(self._callSuperSetUpClass)
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
125 return d
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
126
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
127 def tearDownClass(self):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
128 return self.s._dbpool.runInteraction(self.cleandb)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
129
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
130 def init(self, cursor):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
131 self.cleandb(cursor)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
132 cursor.execute("""INSERT INTO nodes (node) VALUES ('pre-existing')""")
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
133 cursor.execute("""INSERT INTO nodes (node) VALUES ('to-be-deleted')""")
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
134 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
135 OWNER.userhost().encode('utf-8'))
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
136 cursor.execute("""INSERT INTO affiliations
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
137 (node_id, entity_id, affiliation)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
138 SELECT nodes.id, entities.id, 'owner'
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
139 FROM nodes, entities
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
140 WHERE node='pre-existing' AND jid=%s""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
141 OWNER.userhost().encode('utf-8'))
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
142 cursor.execute("""INSERT INTO entities (jid) VALUES (%s)""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
143 SUBSCRIBER.userhost().encode('utf-8'))
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
144 cursor.execute("""INSERT INTO subscriptions
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
145 (node_id, entity_id, resource, subscription)
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
146 SELECT nodes.id, entities.id, %s, 'subscribed'
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
147 FROM nodes, entities
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
148 WHERE node='pre-existing' AND jid=%s""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
149 (SUBSCRIBER.resource.encode('utf-8'),
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
150 SUBSCRIBER.userhost().encode('utf-8')))
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
151
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
152 def cleandb(self, cursor):
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
153 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
154 ('non-existing', 'pre-existing', 'to-be-deleted',
bc872c33e88c Added test cases for a few of the Node methods.
Ralph Meijer <ralphm@ik.nu>
parents: 114
diff changeset
155 'new 1', 'new 2', 'new 3')""")
114
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
156 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
157 OWNER.userhost().encode('utf-8'))
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
158 cursor.execute("""DELETE FROM entities WHERE jid=%s""",
e7cfe05bc1d2 Initial revision.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
159 SUBSCRIBER.userhost().encode('utf-8'))