Ejemplo n.º 1
0
def test_inbox_get_nowait_returns_none():
    """Test that getting an envelope from an empty inbox returns None."""
    # TODO get_nowait in this case should raise an exception, like it's done in queue.Queue
    multiplexer = Multiplexer(
        [DummyConnection(connection_id=DUMMY_CONNECTION_PUBLIC_ID)])
    inbox = InBox(multiplexer)
    assert inbox.get_nowait() is None
Ejemplo n.º 2
0
def test_inbox_nowait():
    """Tests the inbox without waiting."""
    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_nowait(
    ) == envelope, "Check for a message on the in queue and wait for no time."
Ejemplo n.º 3
0
def test_inbox_nowait():
    """Tests the inbox without waiting."""
    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_nowait() == envelope
            ), "Check for a message on the in queue and wait for no time."
Ejemplo n.º 4
0
def test_inbox_get_nowait_returns_none():
    """Test that getting an envelope from an empty inbox returns None."""
    # TODO get_nowait in this case should raise an exception, like it's done in queue.Queue
    multiplexer = Multiplexer([_make_dummy_connection()])
    inbox = InBox(multiplexer)
    assert inbox.get_nowait() is None