コード例 #1
0
ファイル: test_actor_json.py プロジェクト: sdss/clu
async def test_json_actor_command_write(json_actor, json_client):

    command = Command(
        command_string="ping",
        actor=json_actor,
    )

    command.set_status("RUNNING")
    command.write("i", text="Pong")

    assert len(command.replies) == 2
    assert command.replies[0].message_code == ">"
コード例 #2
0
ファイル: test_actor.py プロジェクト: sdss/clu
async def test_write_exception(actor):

    command = Command(
        command_string="ping",
        actor=actor,
    )

    command.set_status("RUNNING")
    command.write("e", error=ValueError("Error message"))

    assert len(command.replies) == 2
    assert command.replies[1].message_code == "e"
    assert command.replies[1].message["error"] == "Error message"
コード例 #3
0
def _output(
    command: Command,
    controller: ArchonController,
    text: str,
    message_code="d",
):
    command.write(
        message_code=message_code,
        text=dict(
            controller=controller.name,
            text=text,
        ),
    )
コード例 #4
0
ファイル: test_amqp.py プロジェクト: sdss/clu
async def test_write_exception(amqp_actor):

    command = Command(
        command_string="ping",
        actor=amqp_actor,
    )

    command.set_status("RUNNING")
    command.write("e", error=ValueError("Error message"))

    assert len(command.replies) == 2
    assert command.replies[1].message_code == "e"
    assert command.replies.get("error") == {
        "exception_module": "builtins",
        "exception_type": "ValueError",
        "exception_message": "Error message",
    }