Example #1
0
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_stays_in_state_1_after_second_request(make_transport):
    transport = make_transport()
    request = make_request()
    transport.respond(request)
    transport.respond(request)

    expected = 1
    actual = transport.state
    assert actual == expected
Example #3
0
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
def test_transport_GET_blocks_for_empty_socket(make_transport):
    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
Example #5
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()
Example #6
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()
Example #7
0
def test_sockets_get_adds_channel(mk):
    mk(('echo.sock.spt', '[---]\n'))
    request = make_request()
    request.socket = '1/'

    try:
        sockets.get(request) # handshake

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

    try:
        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()
Example #9
0
def test_channel_survives_transportation():
    mk(('echo.sock', ''))
    request = make_request()
    request.socket = '1/'
    response = sockets.get(request)  # handshake
    sid = response.body.split(':')[0]
    request.socket = '1/xhr-polling/' + sid
    transport = sockets.get(request)  # transport

    try:
        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()