def testEncodingWithExtension(self): msg=ClientMessage() vr=0 optype=200 corrID=0 parID=-1 msg.version=vr msg.optype=optype msg.correlation=corrID msg.partition=parID msg.addExtension(bytearray(ctypes.c_uint32(4203239))) frame = bytearray() #Create a byte array of size 18 frame+=bytearray(ctypes.c_int32(18+4)) frame+=bytearray(ctypes.c_uint8(vr)) frame+=bytearray(ctypes.c_uint8(192)) frame+=bytearray(ctypes.c_uint16(optype)) frame+=bytearray(ctypes.c_int32(corrID)) frame+=bytearray(ctypes.c_int32(parID)) frame+=bytearray(ctypes.c_uint16(22)) frame+=bytearray(ctypes.c_uint32(4203239)) encodedMsg=msg.encodeMessage() self.assertEqual(frame,encodedMsg)
def testEncoding(self): msg=ClientMessage() vr=0 optype=200 corrID=0 parID=-1 msg.setVersion(vr) msg.setFlagBoth() msg.setOperationType(200) msg.correlation=corrID msg.setPartition(parID) frame = bytearray() #Create a byte array of size 18 frame+=bytearray(ctypes.c_int32(18)) frame+=bytearray(ctypes.c_uint8(vr)) frame+=bytearray(ctypes.c_uint8(192)) frame+=bytearray(ctypes.c_uint16(optype)) frame+=bytearray(ctypes.c_int32(corrID)) frame+=bytearray(ctypes.c_int32(parID)) frame+=bytearray(ctypes.c_uint16(18)) self.assertEqual(frame,msg.encodeMessage())
def testHeaderNormal(self): msg=ClientMessage() self.assertEqual(len(msg.encodeMessage()),msg.FRAME_SIZE)