Beispiel #1
0
def test_send_receive_with_none_context():
    """
    Test attempting to start a TCP server using context values, with no context
    set. Verify expected ValueError is raised.
    """
    with path.TemporaryDirectory() as runpath:
        client = TCPClient(name='client',
                           host=context('server', '{{host}}'),
                           port=context('server', '{{port}}'),
                           runpath=runpath)
    with pytest.raises(ValueError):
        client.start()
Beispiel #2
0
def test_send_receive_with_none_context(runpath):
    """
    Test attempting to start a TCP server using context values, with no context
    set. Verify expected ValueError is raised.
    """
    client = TCPClient(
        name="client",
        host=context("server", "{{host}}"),
        port=context("server", "{{port}}"),
        runpath=runpath,
    )
    with pytest.raises(ValueError):
        client.start()
Beispiel #3
0
def test_send_receive_no_context():
    server = TCPServer(name='server', host='localhost', port=0)
    assert server.port is None
    server.start()
    server._wait_started()
    assert server.port != 0

    client = TCPClient(name='client', host=server._host, port=server._port)
    client.start()
    client._wait_started()

    send_receive_message(server, client)
    client.stop()
    client._wait_stopped()
    server.stop()
    server._wait_stopped()