Ejemplo n.º 1
0
    async def unhandled_message(self, response) -> None:
        body = proto.NotHandled()
        body.ParseFromString(response.payload)

        if body.reason == NotHandledReason.NotReady:
            exn = exceptions.NotReady(self.conversation_id)
        elif body.reason == NotHandledReason.TooBusy:
            exn = exceptions.TooBusy(self.conversation_id)
        elif body.reason == NotHandledReason.NotMaster:
            exn = exceptions.NotMaster(self.conversation_id)
        else:
            exn = exceptions.NotHandled(self.conversation_id, body.reason)

        return await self.error(exn)
Ejemplo n.º 2
0
async def test_not_master():

    output = TeeQueue()
    payload = proto.NotHandled()
    payload.reason = msg.NotHandledReason.NotMaster

    conversation = Ping()
    await conversation.respond_to(
        msg.InboundMessage(uuid4(), msg.TcpCommand.NotHandled,
                           payload.SerializeToString()),
        output,
    )

    with pytest.raises(exn.NotMaster) as exc:
        await conversation.result
        assert exc.conversation_id == conversation.conversation_id
Ejemplo n.º 3
0
async def test_notready_message():

    output = TeeQueue()
    payload = proto.NotHandled()
    payload.reason = msg.NotHandledReason.NotReady
    conversation = Ping()

    with pytest.raises(exn.NotReady):
        await conversation.respond_to(
            msg.InboundMessage(uuid4(), msg.TcpCommand.NotHandled,
                               payload.SerializeToString()),
            output,
        )

        await conversation.result

    assert conversation.is_complete