Commit 5cb770e5 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Replace failUnless() with assertTrue()

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1492 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent af374f83
......@@ -117,7 +117,7 @@ class ZODBTests(NEOFunctionalTest):
else:
raise
else:
self.failUnless(not abort_it, 'Did not abort duplication')
self.assertTrue(not abort_it, 'Did not abort duplication')
l1 = list(ob.items())
l1.sort()
l2 = list(ob2.items())
......
......@@ -76,7 +76,7 @@ class MasterClientHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.askBeginTransaction(conn, packet, None)
self.failUnless(ltid < self.app.tm.getLastTID())
self.assertTrue(ltid < self.app.tm.getLastTID())
self.assertEqual(len(self.app.tm.getPendingList()), 1)
tid = self.app.tm.getPendingList()[0]
self.assertEquals(tid, self.app.tm.getLastTID())
......@@ -91,7 +91,7 @@ class MasterClientHandlerTests(NeoTestBase):
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
conn = self.getFakeConnection(client_uuid, self.client_address)
service.askNewOIDs(conn, packet, 1)
self.failUnless(loid < self.app.loid)
self.assertTrue(loid < self.app.loid)
def test_09_finishTransaction(self):
service = self.service
......
......@@ -47,7 +47,7 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(len(partition_list), num_partitions)
for x in xrange(num_partitions):
part = partition_list[x]
self.failUnless(isinstance(part, list))
self.assertTrue(isinstance(part, list))
self.assertEqual(len(part), 0)
self.assertEqual(len(pt.count_dict), 0)
# no nodes or cells for now
......@@ -125,8 +125,8 @@ class MasterPartitionTableTests(NeoTestBase):
cells_outdated = pt.outdate()
self.assertEqual(len(cells_outdated), 3)
for offset, uuid, state in cells_outdated:
self.failUnless(offset in (1,2,3))
self.failUnless(uuid in (uuid2,uuid3,uuid4))
self.assertTrue(offset in (1,2,3))
self.assertTrue(uuid in (uuid2,uuid3,uuid4))
self.assertEqual(state, CellStates.OUT_OF_DATE)
# check each cell
# part 1, already outdated
......@@ -190,7 +190,7 @@ class MasterPartitionTableTests(NeoTestBase):
for x in xrange(num_replicas):
self.assertEqual(len(pt.getCellList(x)), 2)
self.assertEqual(pt.getCellList(x)[0].getState(), CellStates.OUT_OF_DATE)
self.failUnless(pt.getCellList(x)[0].getNode() in (sn1, sn2))
self.assertTrue(pt.getCellList(x)[0].getNode() in (sn1, sn2))
# test the most used node is remove from some partition
uuid3 = self.getNewUUID()
server3 = ("127.0.0.3", 19001)
......@@ -231,9 +231,9 @@ class MasterPartitionTableTests(NeoTestBase):
elif uuid == uuid6:
self.assertEqual(state, CellStates.OUT_OF_DATE)
else:
self.failUnless(uuid in (uuid1, uuid6))
self.assertTrue(uuid in (uuid1, uuid6))
else:
self.failUnless(offset in (0, 1))
self.assertTrue(offset in (0, 1))
for x in xrange(num_replicas):
self.assertEqual(len(pt.getCellList(x)), 2)
# there is a feeding cell, just dropped
......@@ -260,9 +260,9 @@ class MasterPartitionTableTests(NeoTestBase):
elif uuid == uuid6:
self.assertEqual(state, CellStates.OUT_OF_DATE)
else:
self.failUnless(uuid in (uuid1, uuid6))
self.assertTrue(uuid in (uuid1, uuid6))
else:
self.failUnless(offset in (0, 1))
self.assertTrue(offset in (0, 1))
for x in xrange(num_replicas):
self.assertEqual(len(pt.getCellList(x)), 3)
# there is no feeding cell, marked as feeding
......@@ -285,9 +285,9 @@ class MasterPartitionTableTests(NeoTestBase):
elif uuid == uuid6:
self.assertEqual(state, CellStates.OUT_OF_DATE)
else:
self.failUnless(uuid in (uuid1, uuid6))
self.assertTrue(uuid in (uuid1, uuid6))
else:
self.failUnless(offset in (0, 1))
self.assertTrue(offset in (0, 1))
for x in xrange(num_replicas):
self.assertEqual(len(pt.getCellList(x)), 3)
......@@ -332,7 +332,7 @@ class MasterPartitionTableTests(NeoTestBase):
elif uuid == uuid4:
self.assertEqual(state, CellStates.OUT_OF_DATE)
else:
self.failUnless(uuid in (uuid2, uuid4))
self.assertTrue(uuid in (uuid2, uuid4))
for x in xrange(num_replicas):
self.assertEqual(len(pt.getCellList(x)), 2)
......@@ -390,8 +390,8 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(len(cells), 2)
nodes = [x.getNode() for x in cells]
for node in nodes:
self.failUnless(node in (sn1, sn4, sn5))
self.failUnless(node not in (sn2, sn3))
self.assertTrue(node in (sn1, sn4, sn5))
self.assertTrue(node not in (sn2, sn3))
self.assertTrue(pt.filled())
self.assertTrue(pt.operational())
# create a pt with less nodes
......@@ -471,7 +471,7 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(cell.getState(), CellStates.UP_TO_DATE)
else:
self.assertEqual(cell.getState(), CellStates.OUT_OF_DATE)
self.failUnless(sn2 in [x.getNode() for x in cells])
self.assertTrue(sn2 in [x.getNode() for x in cells])
# check part 2
cells = pt.getCellList(1)
......@@ -481,8 +481,8 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(cell.getState(), CellStates.FEEDING)
else:
self.assertEqual(cell.getState(), CellStates.OUT_OF_DATE)
self.failUnless(sn3 in [x.getNode() for x in cells])
self.failUnless(sn1 in [x.getNode() for x in cells])
self.assertTrue(sn3 in [x.getNode() for x in cells])
self.assertTrue(sn1 in [x.getNode() for x in cells])
# check part 3
cells = pt.getCellList(2)
......@@ -492,8 +492,8 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(cell.getState(), CellStates.UP_TO_DATE)
else:
self.assertEqual(cell.getState(), CellStates.OUT_OF_DATE)
self.failUnless(sn3 in [x.getNode() for x in cells])
self.failUnless(sn2 in [x.getNode() for x in cells])
self.assertTrue(sn3 in [x.getNode() for x in cells])
self.assertTrue(sn2 in [x.getNode() for x in cells])
# check part 4
cells = pt.getCellList(3)
......@@ -509,8 +509,8 @@ class MasterPartitionTableTests(NeoTestBase):
self.assertEqual(cell.getState(), CellStates.UP_TO_DATE)
else:
self.assertEqual(cell.getState(), CellStates.OUT_OF_DATE)
self.failUnless(sn1 in [x.getNode() for x in cells])
self.failUnless(sn5 in [x.getNode() for x in cells])
self.assertTrue(sn1 in [x.getNode() for x in cells])
self.assertTrue(sn5 in [x.getNode() for x in cells])
if __name__ == '__main__':
......
......@@ -107,9 +107,9 @@ class MasterRecoveryTests(NeoTestBase):
new_oid = pack('!Q', oid + 1)
upper, lower = unpack('!LL', ltid)
new_tid = pack('!LL', upper, lower + 10)
self.failUnless(new_ptid > self.app.pt.getID())
self.failUnless(new_oid > self.app.loid)
self.failUnless(new_tid > self.app.tm.getLastTID())
self.assertTrue(new_ptid > self.app.pt.getID())
self.assertTrue(new_oid > self.app.loid)
self.assertTrue(new_tid > self.app.tm.getLastTID())
self.assertEquals(self.app.target_uuid, None)
recovery.answerLastIDs(conn, packet, new_oid, new_tid, new_ptid)
self.assertEquals(new_oid, self.app.loid)
......
......@@ -186,7 +186,7 @@ class MasterStorageHandlerTests(NeoTestBase):
lptid = self.app.pt.getID()
method(conn1)
self.assertEquals(node1.getState(), state)
self.failUnless(lptid < self.app.pt.getID())
self.assertTrue(lptid < self.app.pt.getID())
# drop the second, no storage node left
lptid = self.app.pt.getID()
self.assertEquals(node2.getState(), NodeStates.RUNNING)
......
......@@ -117,9 +117,9 @@ class MasterVerificationTests(NeoTestBase):
new_oid = pack('!Q', oid + 1)
upper, lower = unpack('!LL', ltid)
new_tid = pack('!LL', upper, lower + 10)
self.failUnless(new_ptid > self.app.pt.getID())
self.failUnless(new_oid > self.app.loid)
self.failUnless(new_tid > self.app.tm.getLastTID())
self.assertTrue(new_ptid > self.app.pt.getID())
self.assertTrue(new_oid > self.app.loid)
self.assertTrue(new_tid > self.app.tm.getLastTID())
self.assertRaises(VerificationFailure, verification.answerLastIDs, conn, packet, new_oid, new_tid, new_ptid)
self.assertNotEquals(new_oid, self.app.loid)
self.assertNotEquals(new_tid, self.app.tm.getLastTID())
......
......@@ -114,12 +114,12 @@ class StorageAppTests(NeoTestBase):
self.assertEqual(cell_list[0].getUUID(), client_uuid)
cell_list = self.app.pt.getCellList(1)
self.assertEqual(len(cell_list), 2)
self.failUnless(cell_list[0].getUUID() in (client_uuid, storage_uuid))
self.failUnless(cell_list[1].getUUID() in (client_uuid, storage_uuid))
self.assertTrue(cell_list[0].getUUID() in (client_uuid, storage_uuid))
self.assertTrue(cell_list[1].getUUID() in (client_uuid, storage_uuid))
cell_list = self.app.pt.getCellList(2)
self.assertEqual(len(cell_list), 2)
self.failUnless(cell_list[0].getUUID() in (master_uuid, storage_uuid))
self.failUnless(cell_list[1].getUUID() in (master_uuid, storage_uuid))
self.assertTrue(cell_list[0].getUUID() in (master_uuid, storage_uuid))
self.assertTrue(cell_list[1].getUUID() in (master_uuid, storage_uuid))
def test_02_queueEvent(self):
self.assertEqual(len(self.app.event_queue), 0)
......
......@@ -79,7 +79,7 @@ class ConnectionTests(NeoTestBase):
# add connector
connector = bc.connector_handler()
bc.setConnector(connector)
self.failUnless(isinstance(bc.getConnector(), DoNothingConnector))
self.assertTrue(isinstance(bc.getConnector(), DoNothingConnector))
self.assertNotEqual(bc.getConnector(), None)
# check it registered the connection in epoll
self.assertEquals(len(em.mockGetNamedCalls("register")), 1)
......@@ -164,7 +164,7 @@ class ConnectionTests(NeoTestBase):
next_id = bc._getNextId()
self.assertEqual(next_id, cur_id)
next_id = bc._getNextId()
self.failUnless(next_id > cur_id)
self.assertTrue(next_id > cur_id)
# test overflow of next id
bc.cur_id = 0xffffffff
next_id = bc._getNextId()
......@@ -959,7 +959,7 @@ class ConnectionTests(NeoTestBase):
next_id = bc._getNextId()
self.assertEqual(next_id, cur_id)
next_id = bc._getNextId()
self.failUnless(next_id > cur_id)
self.assertTrue(next_id > cur_id)
# test overflow of next id
bc.cur_id = 0xffffffff
next_id = bc._getNextId()
......@@ -1083,7 +1083,7 @@ class ConnectionTests(NeoTestBase):
next_id = bc._getNextId()
self.assertEqual(next_id, cur_id)
next_id = bc._getNextId()
self.failUnless(next_id > cur_id)
self.assertTrue(next_id > cur_id)
# test overflow of next id
bc.cur_id = 0xffffffff
next_id = bc._getNextId()
......
......@@ -36,7 +36,7 @@ class EventTests(NeoTestBase):
self.assertEqual(len(em.reader_set), 0)
self.assertEqual(len(em.writer_set), 0)
self.assertEqual(len(em.event_list), 0)
self.failUnless(em.prev_time <time)
self.assertTrue(em.prev_time <time)
self.assertTrue(isinstance(em.epoll, Epoll))
# use a mock object instead of epoll
em.epoll = Mock()
......@@ -160,7 +160,7 @@ class EventTests(NeoTestBase):
# call with time < t < critical_time
t = time + 5
self.failUnless(t < critical_time)
self.assertTrue(t < critical_time)
r = event(t)
self.assertTrue(r)
self.assertEquals(len(conn.mockGetNamedCalls("lock")), 1)
......@@ -173,7 +173,7 @@ class EventTests(NeoTestBase):
# call with time < critical_time < t
t = critical_time + 5
self.failUnless(t > critical_time)
self.assertTrue(t > critical_time)
r = event(t)
self.assertTrue(r)
self.assertEquals(len(conn.mockGetNamedCalls("lock")), 2)
......@@ -211,7 +211,7 @@ class EventTests(NeoTestBase):
# call with time < t < critical_time
t = time + 1
self.failUnless(t < critical_time)
self.assertTrue(t < critical_time)
r = event(t)
self.assertTrue(r)
self.assertEquals(len(conn.mockGetNamedCalls("lock")), 1)
......@@ -224,7 +224,7 @@ class EventTests(NeoTestBase):
# call with time < critical_time < t
t = critical_time + 5
self.failUnless(t > critical_time)
self.assertTrue(t > critical_time)
r = event(t)
self.assertTrue(r)
self.assertEquals(len(conn.mockGetNamedCalls("lock")), 2)
......
......@@ -192,34 +192,34 @@ class PartitionTableTests(NeoTestBase):
all_cell = pt.getCellList(0)
all_nodes = [x.getNode() for x in all_cell]
self.assertEqual(len(all_cell), 3)
self.failUnless(sn1 in all_nodes)
self.failUnless(sn2 in all_nodes)
self.failUnless(sn3 in all_nodes)
self.failUnless(sn4 not in all_nodes)
self.assertTrue(sn1 in all_nodes)
self.assertTrue(sn2 in all_nodes)
self.assertTrue(sn3 in all_nodes)
self.assertTrue(sn4 not in all_nodes)
# writable nodes
all_cell = pt.getCellList(0, writable=True)
all_nodes = [x.getNode() for x in all_cell]
self.assertEqual(len(all_cell), 3)
self.failUnless(sn1 in all_nodes)
self.failUnless(sn2 in all_nodes)
self.failUnless(sn3 in all_nodes)
self.failUnless(sn4 not in all_nodes)
self.assertTrue(sn1 in all_nodes)
self.assertTrue(sn2 in all_nodes)
self.assertTrue(sn3 in all_nodes)
self.assertTrue(sn4 not in all_nodes)
# readable nodes
all_cell = pt.getCellList(0, readable=True)
all_nodes = [x.getNode() for x in all_cell]
self.assertEqual(len(all_cell), 2)
self.failUnless(sn1 in all_nodes)
self.failUnless(sn2 not in all_nodes)
self.failUnless(sn3 in all_nodes)
self.failUnless(sn4 not in all_nodes)
self.assertTrue(sn1 in all_nodes)
self.assertTrue(sn2 not in all_nodes)
self.assertTrue(sn3 in all_nodes)
self.assertTrue(sn4 not in all_nodes)
# writable & readable nodes
all_cell = pt.getCellList(0, readable=True, writable=True)
all_nodes = [x.getNode() for x in all_cell]
self.assertEqual(len(all_cell), 2)
self.failUnless(sn1 in all_nodes)
self.failUnless(sn2 not in all_nodes)
self.failUnless(sn3 in all_nodes)
self.failUnless(sn4 not in all_nodes)
self.assertTrue(sn1 in all_nodes)
self.assertTrue(sn2 not in all_nodes)
self.assertTrue(sn3 in all_nodes)
self.assertTrue(sn4 not in all_nodes)
else:
self.assertEqual(len(pt.getCellList(1, False)), 0)
self.assertEqual(len(pt.getCellList(1, True)), 0)
......@@ -251,7 +251,7 @@ class PartitionTableTests(NeoTestBase):
self.assertEqual(len(partition_list), num_partitions)
for x in xrange(num_partitions):
part = partition_list[x]
self.failUnless(isinstance(part, list))
self.assertTrue(isinstance(part, list))
self.assertEqual(len(part), 0)
self.assertEqual(len(pt.count_dict), 0)
......@@ -280,10 +280,10 @@ class PartitionTableTests(NeoTestBase):
# into account
self.assertEqual(len(pt.getNodeList()), 2)
nodes = pt.getNodeList()
self.failUnless(sn1 in nodes)
self.failUnless(sn2 in nodes)
self.failUnless(sn3 not in nodes)
self.failUnless(sn4 not in nodes)
self.assertTrue(sn1 in nodes)
self.assertTrue(sn2 in nodes)
self.assertTrue(sn3 not in nodes)
self.assertTrue(sn4 not in nodes)
def test_08_filled(self):
num_partitions = 5
......@@ -400,12 +400,12 @@ class PartitionTableTests(NeoTestBase):
row_0 = pt.getRow(0)
self.assertEqual(len(row_0), 3)
for uuid, state in row_0:
self.failUnless(uuid in (sn1.getUUID(), sn2.getUUID(), sn3.getUUID()))
self.assertTrue(uuid in (sn1.getUUID(), sn2.getUUID(), sn3.getUUID()))
self.assertEqual(state, CellStates.UP_TO_DATE)
row_1 = pt.getRow(1)
self.assertEqual(len(row_1), 2)
for uuid, state in row_1:
self.failUnless(uuid in (sn1.getUUID(), sn2.getUUID()))
self.assertTrue(uuid in (sn1.getUUID(), sn2.getUUID()))
self.assertEqual(state, CellStates.UP_TO_DATE)
row_2 = pt.getRow(2)
self.assertEqual(len(row_2), 1)
......
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