Пример #1
0
def test_inbox_get_raises_exception_when_empty():
    """Test that getting an envelope from an empty inbox raises an exception."""
    multiplexer = Multiplexer([DummyConnection()])
    inbox = InBox(multiplexer)

    with pytest.raises(aea.mail.base.Empty):
        with unittest.mock.patch.object(multiplexer, "get", return_value=None):
            inbox.get()
Пример #2
0
def test_inbox_get():
    """Tests for a envelope on the in queue."""
    msg = Message(content="hello")
    message_bytes = ProtobufSerializer().encode(msg)
    my_queue = Queue()
    envelope = Envelope(to="Agent1",
                        sender="Agent0",
                        protocol_id="my_own_protocol",
                        message=message_bytes)
    my_queue.put(envelope)
    _inbox = InBox(my_queue)

    assert _inbox.get() == envelope,\
        "Checks if the returned envelope is the same with the queued envelope."
Пример #3
0
def test_inbox_get():
    """Tests for a envelope on the in queue."""
    msg = Message(content="hello")
    message_bytes = ProtobufSerializer().encode(msg)
    multiplexer = Multiplexer([DummyConnection()])
    envelope = Envelope(to="Agent1",
                        sender="Agent0",
                        protocol_id="my_own_protocol",
                        message=message_bytes)
    multiplexer.in_queue.put(envelope)
    inbox = InBox(multiplexer)

    assert inbox.get(
    ) == envelope, "Checks if the returned envelope is the same with the queued envelope."
Пример #4
0
def test_inbox_get():
    """Tests for a envelope on the in queue."""
    msg = Message(content="hello")
    message_bytes = ProtobufSerializer().encode(msg)
    multiplexer = Multiplexer([_make_dummy_connection()])
    envelope = Envelope(
        to="Agent1",
        sender="Agent0",
        protocol_id=UNKNOWN_PROTOCOL_PUBLIC_ID,
        message=message_bytes,
    )
    multiplexer.in_queue.put(envelope)
    inbox = InBox(multiplexer)

    assert (
        inbox.get() == envelope
    ), "Checks if the returned envelope is the same with the queued envelope."