def buildErrorReply(self, error_message): message = Message(id=555, type=Message.REFLECTION_RESPONSE) message.reflection_response.session_id = "555" message.reflection_response.status = Message.ReflectionResponse.ERROR message.reflection_response.errormessage = error_message return message
def buildObjectReply(self, ref): message = Message(id=555, type=Message.REFLECTION_RESPONSE) message.reflection_response.session_id = "555" message.reflection_response.status = Message.ReflectionResponse.SUCCESS message.reflection_response.result.type = Message.Argument.OBJECT message.reflection_response.result.object.reference = ref return message
def sendAndReceive(self, factory): self.sent = Message() self.sent.ParseFromString( factory.setId(555).setSessionId("555").build()) if len(self.reply_with) > 0: return self.reply_with.pop(0) else: return None
def buildPrimitiveReply(self, type, int): message = Message(id=555, type=Message.REFLECTION_RESPONSE) message.reflection_response.session_id = "555" message.reflection_response.status = Message.ReflectionResponse.SUCCESS message.reflection_response.result.type = Message.Argument.PRIMITIVE message.reflection_response.result.primitive.type = type message.reflection_response.result.primitive.int = int return message
def message(self): """ Extracts the Message from a Frame by parsing the payload into a Message object. """ message = Message() message.ParseFromString(self.payload) return message
def __init__(self): self.builder = Message(type=Message.REFLECTION_RESPONSE) self.builder.reflection_response.status = Message.ReflectionResponse.SUCCESS
def __init__(self, request_type): self.builder = Message(type=Message.REFLECTION_REQUEST) self.builder.reflection_request.type = request_type
def testItShouldShowTheMessageTypeAsSystemResponse(self): message = Message(id=1, type=Message.SYSTEM_RESPONSE).SerializeToString() assert frame.Frame(2, len(message), message).messageType() == "SYSTEM_RESPONSE"
def testItShouldShowTheMessageTypeAsReflectionResponse(self): message = Message( id=1, type=Message.REFLECTION_RESPONSE).SerializeToString() assert frame.Frame(2, len(message), message).messageType() == "REFLECTION_RESPONSE"
def testItShouldExtractTheMessage(self): message = Message(id=1, type=Message.REFLECTION_REQUEST).SerializeToString() assert isinstance( frame.Frame(2, len(message), message).message(), Message)
def testItShouldBuildFrameFromMessage(self): message = Message(id=1, type=Message.REFLECTION_REQUEST).SerializeToString() assert frame.Frame.fromMessage(message).length == len(message)
def __init__(self, response_type): self.builder = Message(type=Message.SYSTEM_RESPONSE) self.builder.system_response.type = response_type self.builder.system_response.status = Message.SystemResponse.SUCCESS
def buildSuccessReply(self): message = Message(id=555, type=Message.REFLECTION_RESPONSE) message.reflection_response.session_id = "555" message.reflection_response.status = Message.ReflectionResponse.SUCCESS return message