Commit c0b9f5b4 authored by Julien Muchembled's avatar Julien Muchembled

Update tests against previous changes to client cache

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2713 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 2c17284f
......@@ -304,8 +304,9 @@ class NeoUnitTestBase(NeoTestBase):
""" ensure no UUID was set on the connection """
calls = conn.mockGetNamedCalls('setUUID')
self.assertEqual(len(calls), 1)
call = calls.pop()
if uuid is not None:
self.assertEqual(calls[0].getParam(0), uuid)
self.assertEqual(call.getParam(0), uuid)
# in check(Ask|Answer|Notify)Packet we return the packet so it can be used
# in tests if more accurates checks are required
......@@ -314,7 +315,7 @@ class NeoUnitTestBase(NeoTestBase):
""" Check if an error packet was answered """
calls = conn.mockGetNamedCalls("answer")
self.assertEqual(len(calls), 1)
packet = calls[0].getParam(0)
packet = calls.pop().getParam(0)
self.assertTrue(isinstance(packet, protocol.Packet))
self.assertEqual(packet.getType(), Packets.Error)
if decode:
......@@ -326,7 +327,7 @@ class NeoUnitTestBase(NeoTestBase):
""" Check if an ask-packet with the right type is sent """
calls = conn.mockGetNamedCalls('ask')
self.assertEqual(len(calls), 1)
packet = calls[0].getParam(0)
packet = calls.pop().getParam(0)
self.assertTrue(isinstance(packet, protocol.Packet))
self.assertEqual(packet.getType(), packet_type)
if decode:
......@@ -337,7 +338,7 @@ class NeoUnitTestBase(NeoTestBase):
""" Check if an answer-packet with the right type is sent """
calls = conn.mockGetNamedCalls('answer')
self.assertEqual(len(calls), 1)
packet = calls[0].getParam(0)
packet = calls.pop().getParam(0)
self.assertTrue(isinstance(packet, protocol.Packet))
self.assertEqual(packet.getType(), packet_type)
if decode:
......@@ -347,8 +348,7 @@ class NeoUnitTestBase(NeoTestBase):
def checkNotifyPacket(self, conn, packet_type, packet_number=0, decode=False):
""" Check if a notify-packet with the right type is sent """
calls = conn.mockGetNamedCalls('notify')
self.assertTrue(len(calls) > packet_number, (len(calls), packet_number))
packet = calls[packet_number].getParam(0)
packet = calls.pop(packet_number).getParam(0)
self.assertTrue(isinstance(packet, protocol.Packet))
self.assertEqual(packet.getType(), packet_type)
if decode:
......@@ -564,7 +564,7 @@ class ClusterPdb(object):
os.write(self._w, pack('d', delay))
def sync(self):
"""Sleep as long as another process acquires the lock"""
"""Sleep as long as another process owns the lock"""
delay = self.acquire()
self.release(delay)
return delay
......
This diff is collapsed.
......@@ -156,21 +156,17 @@ class MasterNotificationsHandlerTests(MasterHandlerTests):
conn = self.getConnection()
tid = self.getNextTID()
oid1, oid2, oid3 = self.getOID(1), self.getOID(2), self.getOID(3)
self.app.mq_cache = {
(oid1, tid): ('bla', None),
(oid2, tid): ('bla', None),
}
self.app.cache_revision_index = Mock({
self.app._cache = Mock({
'invalidate': None,
})
self.handler.invalidateObjects(conn, tid, [oid1, oid3])
cache_calls = self.app.cache_revision_index.mockGetNamedCalls(
'invalidate')
self.assertEqual(len(cache_calls), 1)
cache_calls[0].checkArgs([oid1, oid3], tid)
cache_calls = self.app._cache.mockGetNamedCalls('invalidate')
self.assertEqual(len(cache_calls), 2)
cache_calls[0].checkArgs(oid1, tid)
cache_calls[1].checkArgs(oid3, tid)
invalidation_calls = self.db.mockGetNamedCalls('invalidate')
self.assertEqual(len(invalidation_calls), 1)
invalidation_calls[0].checkArgs(tid, {oid1:tid, oid3:tid})
invalidation_calls[0].checkArgs(tid, [oid1, oid3])
def test_notifyPartitionChanges(self):
conn = self.getConnection()
......
......@@ -87,7 +87,7 @@ class MasterAppTests(NeoUnitTestBase):
self.app.broadcastNodesInformation([s_node])
# check conn
self.checkNotifyNodeInformation(client_conn)
self.assertFalse(client_conn.mockGetNamedCalls('notify'))
self.checkNoPacketSent(master_conn)
self.checkNotifyNodeInformation(storage_conn)
......
......@@ -189,7 +189,7 @@ class StorageDBTests(NeoUnitTestBase):
# two commited versions
self.db.finishTransaction(tid2)
self.assertEqual(self.db.getObject(oid1), OBJECT_T2)
self.assertEqual(self.db.getObject(oid1, tid1), OBJECT_T1_NO_NEXT)
self.assertEqual(self.db.getObject(oid1, tid1), OBJECT_T1_NEXT)
self.assertEqual(self.db.getObject(oid1, before_tid=tid1),
FOUND_BUT_NOT_VISIBLE)
self.assertEqual(self.db.getObject(oid1, tid2), OBJECT_T2)
......
......@@ -97,7 +97,6 @@ class StorageVerificationHandlerTests(NeoUnitTestBase):
'getLastTID': p64(4),
})
self.verification.askLastIDs(conn)
self.checkAnswerLastIDs(conn)
oid, tid, ptid = self.checkAnswerLastIDs(conn, decode=True)
self.assertEqual(oid, last_oid)
self.assertEqual(u64(tid), 4)
......
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