def test_transport_stays_in_state_1_after_second_request():
    transport = make_transport()
    request = make_request()
    transport.respond(request)
    transport.respond(request)
    
    expected = 1 
    actual = transport.state
    assert actual == expected, actual
def test_transport_GET_blocks_for_empty_socket():
    transport = make_transport(state=1)
    
    request = make_request()
    start = time.time()
    response = transport.respond(request)
    end = time.time()
 
    expected = transport.timeout
    actual = round(end - start, 4)
    assert actual > expected, actual
Exemple #3
0
def test_sockets_get_adds_channel():
    mk(('echo.sock', ''))
    request = make_request()
    request.socket = '1/'
    try:
        response = sockets.get(request) # handshake

        expected = '/echo.sock' 
        actual = sockets.__channels__['/echo.sock'].name
        assert actual == expected, actual
    finally:
        sockets.__channels__['/echo.sock'].disconnect_all()
Exemple #4
0
def test_channel_survives_transportation():
    mk(('echo.sock', ''))
    request = make_request()
    request.socket = '1/'
    try:
        response = sockets.get(request) # handshake
        sid = response.body.split(':')[0]
        request.socket = '1/xhr-polling/' + sid
        transport = sockets.get(request)   # transport

        expected = '/echo.sock' 
        actual = sockets.__channels__['/echo.sock'].name
        assert actual == expected, actual

        expected = transport.socket.channel
        actual = sockets.__channels__['/echo.sock']
        assert actual is expected, actual
    finally:
        transport.socket.disconnect()