Commit 8e199966 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Improve storage bootstrap handler tests by introducing checkAskPacket(). It

might be better that all handlers tests classes inherits from a base class that
implements all those kind of common checks.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@518 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 6984c60a
......@@ -130,15 +130,19 @@ server: 127.0.0.1:10020
""" Check if the NotReadyError exception wxas raised """
self.assertRaises(protocol.NotReadyError, method, *args, **kwargs)
def checkAskPacket(self, conn, packet_type):
""" Check if an ask-packet with the right type is send """
calls = conn.mockGetNamedCalls('ask')
self.assertEquals(len(calls), 1)
packet = calls[0].getParam(0)
self.assertTrue(isinstance(packet, Packet))
self.assertEquals(packet.getType(), packet_type)
# Method to test the kind of packet returned in answer
def checkCalledRequestNodeIdentification(self, conn, packet_number=0):
""" Check Request Node Identification has been send"""
self.assertEquals(len(conn.mockGetNamedCalls("ask")), 1)
self.assertEquals(len(conn.mockGetNamedCalls("abort")), 0)
call = conn.mockGetNamedCalls("ask")[packet_number]
packet = call.getParam(0)
self.assertTrue(isinstance(packet, Packet))
self.assertEquals(packet.getType(), REQUEST_NODE_IDENTIFICATION)
self.checkAskPacket(conn, protocol.REQUEST_NODE_IDENTIFICATION)
def checkNoPacketSent(self, conn):
# no packet should be sent
......@@ -509,7 +513,7 @@ server: 127.0.0.1:10020
self.assertTrue(isinstance(self.app.pt, PartitionTable))
self.assertEquals(self.app.ptid, self.app.dm.getPTID())
self.assertEquals(len(conn.mockGetNamedCalls("setUUID")), 1)
self.assertEquals(len(conn.mockGetNamedCalls("ask")), 1)
self.checkAskPacket(conn, protocol.ASK_PRIMARY_MASTER)
def test_09_handleAcceptNodeIdentification5(self):
# no errors
......@@ -547,11 +551,7 @@ server: 127.0.0.1:10020
self.assertEquals(self.app.uuid, self.app.dm.getUUID())
self.assertEquals(self.app.uuid, your_uuid)
# packet
self.assertEquals(len(conn.mockGetNamedCalls("ask")), 1)
call = conn.mockGetNamedCalls("ask")[0]
packet = call.getParam(0)
self.assertTrue(isinstance(packet, Packet))
self.assertEquals(packet.getType(), ASK_PRIMARY_MASTER)
self.checkAskPacket(conn, ASK_PRIMARY_MASTER)
def test_10_handleAnswerPrimaryMaster01(self):
# server connection rejected
......
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