Commit d8fd8409 authored by Grégory Wisniewski's avatar Grégory Wisniewski

iFix some tests.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@679 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c768d431
...@@ -36,18 +36,6 @@ class MasterAppTests(NeoTestBase): ...@@ -36,18 +36,6 @@ class MasterAppTests(NeoTestBase):
def tearDown(self): def tearDown(self):
NeoTestBase.tearDown(self) NeoTestBase.tearDown(self)
def test_01_getNextPartitionTableID(self):
# must raise as we don"t have one
self.assertEqual(self.app.lptid, INVALID_PTID)
self.app.lptid = INVALID_PTID
self.assertRaises(RuntimeError, self.app.getNextPartitionTableID)
# set one
self.app.lptid = p64(23)
nptid = self.app.getNextPartitionTableID()
self.assertEqual(self.app.lptid, nptid)
self.failUnless(u64(self.app.lptid) > 23)
self.assertEqual(u64(self.app.lptid), 24)
def test_02_getNextOID(self): def test_02_getNextOID(self):
# must raise as we don"t have one # must raise as we don"t have one
self.assertEqual(self.app.loid, INVALID_OID) self.assertEqual(self.app.loid, INVALID_OID)
...@@ -70,12 +58,12 @@ class MasterAppTests(NeoTestBase): ...@@ -70,12 +58,12 @@ class MasterAppTests(NeoTestBase):
self.failUnless(tid > ntid) self.failUnless(tid > ntid)
def test_04_getPartition(self): def test_04_getPartition(self):
self.app.num_partitions = 3 self.app.pt.num_partitions = 3
p = self.app.getPartition(p64(1)) p = self.app.getPartition(p64(1))
self.assertEqual(p, 1) self.assertEqual(p, 1)
p = self.app.getPartition(p64(2)) p = self.app.getPartition(p64(2))
self.assertEqual(p, 2) self.assertEqual(p, 2)
p = self.app.getPartition(p64(3)) p = self.app.getPartition(p64(1009)) # 1009 defined in config
self.assertEqual(p, 0) self.assertEqual(p, 0)
def test_05_getNewOIDList(self): def test_05_getNewOIDList(self):
......
...@@ -27,6 +27,18 @@ from neo.node import StorageNode ...@@ -27,6 +27,18 @@ from neo.node import StorageNode
class MasterPartitionTableTests(NeoTestBase): class MasterPartitionTableTests(NeoTestBase):
def _test_01_setNextID(self):
pt = PartitionTable(100, 2)
# must raise as we don"t have one
self.assertEqual(pt.getID(), INVALID_PTID)
self.assertRaises(RuntimeError, pt.setNextID)
# set one
pt.setID(p64(23))
nptid = pt.setNextID()
self.assertEqual(pt.getID(), nptid)
self.assertTrue(u64(pt.getID()) > 23)
self.assertEqual(u64(pt.getID()), 24)
def test_02_PartitionTable_creation(self): def test_02_PartitionTable_creation(self):
num_partitions = 5 num_partitions = 5
num_replicas = 3 num_replicas = 3
......
...@@ -613,7 +613,7 @@ class MasterServiceTests(NeoTestBase): ...@@ -613,7 +613,7 @@ class MasterServiceTests(NeoTestBase):
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, OUT_OF_DATE_STATE) self.assertEquals(state, OUT_OF_DATE_STATE)
service.handleNotifyPartitionChanges(conn, packet, self.app.lptid, cell_list) service.handleNotifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, OUT_OF_DATE_STATE) self.assertEquals(state, OUT_OF_DATE_STATE)
...@@ -625,7 +625,7 @@ class MasterServiceTests(NeoTestBase): ...@@ -625,7 +625,7 @@ class MasterServiceTests(NeoTestBase):
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, OUT_OF_DATE_STATE) self.assertEquals(state, OUT_OF_DATE_STATE)
service.handleNotifyPartitionChanges(conn, packet, self.app.lptid, cell_list) service.handleNotifyPartitionChanges(conn, packet, self.app.pt.getID(), cell_list)
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, OUT_OF_DATE_STATE) self.assertEquals(state, OUT_OF_DATE_STATE)
......
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