Ejemplo n.º 1
0
def test_slow_streaming():
    """
    TEST THAT THE app ACTUALLY STREAMS.  WE SHOULD GET A RESPONSE BEFORE THE SERVER
    FINISHES DELIVERING
    """
    slow_server_thread = Thread.run("run slow server", run_slow_server)
    proxy_thread = Thread.run("run proxy", run_proxy)

    try:
        proxy_is_ready.wait_for_go()
        server_is_ready.wait_for_go()

        start = time.clock()
        response = requests.get("http://localhost:" + str(PROXY_PORT) + PATH,
                                stream=True)
        for i, data in enumerate(stream(response.raw)):
            Log.note("CLIENT GOT RESPONSE:\n{{data|indent}}", {"data": data})
            end = time.clock()
            if i == 0 and end - start > 10:  # IF WE GET DATA BEFORE 10sec, THEN WE KNOW WE ARE STREAMING
                Log.error("should have something by now")
        if response.status_code != 200:
            Log.error("Expecting a positive response")

    except Exception, e:
        Log.error("Not expected", e)
Ejemplo n.º 2
0
def main():
    url = "http://localhost:9292"
    thread = Thread.run("run app", run_app)

    try:
        server_is_ready.wait_for_go()
        all_tests(url)
    finally:
        thread.please_stop.go()
        Log.stop()
Ejemplo n.º 3
0
def main():
    url = "http://localhost:9292"
    thread = Thread.run("run app", run_app)

    try:
        server_is_ready.wait_for_go()
        all_tests(url)
    finally:
        thread.please_stop.go()
        Log.stop()
Ejemplo n.º 4
0
def test_slow_streaming():
    """
    TEST THAT THE app ACTUALLY STREAMS.  WE SHOULD GET A RESPONSE BEFORE THE SERVER
    FINISHES DELIVERING
    """
    slow_server_thread = Thread.run("run slow server", run_slow_server)
    proxy_thread = Thread.run("run proxy", run_proxy)

    try:
        proxy_is_ready.wait_for_go()
        server_is_ready.wait_for_go()

        start = time.clock()
        response = requests.get("http://localhost:" + str(PROXY_PORT) + PATH, stream=True)
        for i, data in enumerate(stream(response.raw)):
            Log.note("CLIENT GOT RESPONSE:\n{{data|indent}}", {"data": data})
            end = time.clock()
            if i == 0 and end - start > 10:  # IF WE GET DATA BEFORE 10sec, THEN WE KNOW WE ARE STREAMING
                Log.error("should have something by now")
        if response.status_code != 200:
            Log.error("Expecting a positive response")

    except Exception, e:
        Log.error("Not expected", e)