Commit d9b47fe8 authored by Vincent Pelletier's avatar Vincent Pelletier

Remove SQL queries from testStorageApp.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2260 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0ca708ac
...@@ -37,7 +37,9 @@ class StorageAppTests(NeoTestBase): ...@@ -37,7 +37,9 @@ class StorageAppTests(NeoTestBase):
NeoTestBase.tearDown(self) NeoTestBase.tearDown(self)
def test_01_loadPartitionTable(self): def test_01_loadPartitionTable(self):
self.assertEqual(len(self.app.dm.getPartitionTable()), 0) self.app.dm = Mock({
'getPartitionTable': [],
})
self.assertEqual(self.app.pt, None) self.assertEqual(self.app.pt, None)
num_partitions = 3 num_partitions = 3
num_replicas = 2 num_replicas = 2
...@@ -71,7 +73,6 @@ class StorageAppTests(NeoTestBase): ...@@ -71,7 +73,6 @@ class StorageAppTests(NeoTestBase):
else: else:
self.assertFalse(self.app.pt.hasOffset(x)) self.assertFalse(self.app.pt.hasOffset(x))
# load an empty table, everything removed # load an empty table, everything removed
self.assertEqual(len(self.app.dm.getPartitionTable()), 0)
self.app.loadPartitionTable() self.app.loadPartitionTable()
self.assertEqual(self.app.pt.getNodeList(), []) self.assertEqual(self.app.pt.getNodeList(), [])
self.assertFalse(self.app.pt.filled()) self.assertFalse(self.app.pt.filled())
...@@ -89,19 +90,16 @@ class StorageAppTests(NeoTestBase): ...@@ -89,19 +90,16 @@ class StorageAppTests(NeoTestBase):
else: else:
self.assertFalse(self.app.pt.hasOffset(x)) self.assertFalse(self.app.pt.hasOffset(x))
# fill partition table # fill partition table
self.app.dm.setPTID(1) self.app.dm = Mock({
self.app.dm.query('delete from pt;') 'getPartitionTable': [
self.app.dm.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" % (0, client_uuid, CellStates.UP_TO_DATE),
(0, dump(client_uuid), CellStates.UP_TO_DATE)) (1, client_uuid, CellStates.UP_TO_DATE),
self.app.dm.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" % (1, storage_uuid, CellStates.UP_TO_DATE),
(1, dump(client_uuid), CellStates.UP_TO_DATE)) (2, storage_uuid, CellStates.UP_TO_DATE),
self.app.dm.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" % (2, master_uuid, CellStates.UP_TO_DATE),
(1, dump(storage_uuid), CellStates.UP_TO_DATE)) ],
self.app.dm.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" % 'getPTID': 1,
(2, dump(storage_uuid), CellStates.UP_TO_DATE)) })
self.app.dm.query("insert into pt (rid, uuid, state) values ('%s', '%s', %d)" %
(2, dump(master_uuid), CellStates.UP_TO_DATE))
self.assertEqual(len(self.app.dm.getPartitionTable()), 5)
self.app.pt.clear() self.app.pt.clear()
self.app.loadPartitionTable() self.app.loadPartitionTable()
self.assertTrue(self.app.pt.filled()) self.assertTrue(self.app.pt.filled())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment