Esempio n. 1
0
def check_client_connect(server_impl):
    client = Client(type=317)
    eq_(client.type, 317)
    future = client.connect(server.server_address)
    if server_impl is SimpleMxServerThread:
        # we can't use conect future, as we can't rely on
        # SimpleMxServerThread correctly sending welcome messages
        time.sleep(0.07)
    else:
        future.wait(0.2)

    msg = client.create_message(id=5)
    assert_almost_equal(msg.timestamp, time.time(), -1)
    eq_(dict(dict_message(msg), timestamp=None), {'timestamp': None, 'id':
        5, 'from': client.instance_id})

    client.close()
Esempio n. 2
0
def test_client_shutdown():
    c = Client(type=317)
    # no close

    c = Client(type=317)
    c.close()

    c = Client(type=317)
    c.close()

    c = Client(type=317)
    c.close()
    c.close() # redundant

    with closing(Client(type=317)):
        pass

    with create_test_client():
        pass