Exemplo n.º 1
0
def test_outbox_put():
    """Tests that an envelope is putted into the queue."""
    msg = DefaultMessage(
        dialogue_reference=("", ""),
        message_id=1,
        target=0,
        performative=DefaultMessage.Performative.BYTES,
        content=b"hello",
    )
    message_bytes = DefaultSerializer().encode(msg)
    multiplexer = Multiplexer(
        [DummyConnection(connection_id=DUMMY_CONNECTION_PUBLIC_ID)])
    outbox = OutBox(multiplexer)
    inbox = InBox(multiplexer)
    multiplexer.connect()
    envelope = Envelope(
        to="Agent1",
        sender="Agent0",
        protocol_id=DefaultMessage.protocol_id,
        message=message_bytes,
    )
    outbox.put(envelope)
    time.sleep(0.5)
    assert not inbox.empty(
    ), "Inbox must not be empty after putting an envelope"
    multiplexer.disconnect()
Exemplo n.º 2
0
def test_outbox_put_message():
    """Tests that an envelope is created from the message is in the queue."""
    msg = DefaultMessage(type=DefaultMessage.Type.BYTES, content=b"hello")
    message_bytes = DefaultSerializer().encode(msg)
    multiplexer = Multiplexer([DummyConnection()])
    outbox = OutBox(multiplexer)
    inbox = InBox(multiplexer)
    multiplexer.connect()
    outbox.put_message("Agent1", "Agent0", DefaultMessage.protocol_id,
                       message_bytes)
    time.sleep(0.5)
    assert not inbox.empty(
    ), "Inbox will not be empty after putting a message."
    multiplexer.disconnect()
Exemplo n.º 3
0
def test_outbox_put():
    """Tests that an envelope is putted into the queue."""
    msg = DefaultMessage(type=DefaultMessage.Type.BYTES, content=b"hello")
    message_bytes = DefaultSerializer().encode(msg)
    multiplexer = Multiplexer([DummyConnection()])
    outbox = OutBox(multiplexer)
    inbox = InBox(multiplexer)
    multiplexer.connect()
    envelope = Envelope(to="Agent1",
                        sender="Agent0",
                        protocol_id=DefaultMessage.protocol_id,
                        message=message_bytes)
    outbox.put(envelope)
    time.sleep(0.5)
    assert not inbox.empty(
    ), "Inbox must not be empty after putting an envelope"
    multiplexer.disconnect()
Exemplo n.º 4
0
def test_outbox_put_message():
    """Tests that an envelope is created from the message is in the queue."""
    msg = DefaultMessage(
        dialogue_reference=("", ""),
        message_id=1,
        target=0,
        performative=DefaultMessage.Performative.BYTES,
        content=b"hello",
    )
    message_bytes = DefaultSerializer().encode(msg)
    dummy_connection = _make_dummy_connection()
    multiplexer = Multiplexer([dummy_connection])
    outbox = OutBox(multiplexer)
    inbox = InBox(multiplexer)
    multiplexer.connect()
    outbox.put_message("Agent1", "Agent0", DefaultMessage.protocol_id,
                       message_bytes)
    time.sleep(0.5)
    assert not inbox.empty(
    ), "Inbox will not be empty after putting a message."
    multiplexer.disconnect()
Exemplo n.º 5
0
def test_inbox_empty():
    """Tests if the inbox is empty."""
    multiplexer = Multiplexer([DummyConnection()])
    _inbox = InBox(multiplexer)
    assert _inbox.empty(), "Inbox is not empty"
Exemplo n.º 6
0
def test_inbox_empty():
    """Tests if the inbox is empty."""
    multiplexer = Multiplexer(
        [DummyConnection(connection_id=DUMMY_CONNECTION_PUBLIC_ID)])
    _inbox = InBox(multiplexer)
    assert _inbox.empty(), "Inbox is not empty"
Exemplo n.º 7
0
def test_inbox_empty():
    """Tests if the inbox is empty."""
    my_queue = Queue()
    _inbox = InBox(my_queue)
    assert _inbox.empty(), "Inbox is not empty"