示例#1
0
def test_http_server_thread():
    queue = Queue()
    server_thread = HttpServerThread(
        RequestHandlerClass=QueuingRequestHandler.with_queue(queue))
    server_thread.start()
    port, host, fqdn = server_thread.server_address_info()
    url = 'http://{f}:{p}/foo/bar'.format(f=fqdn, p=port)
    response = requests.get(url)
    response.raise_for_status()
    assert list(drain_queue(queue)) == ['/foo/bar']
    server_thread.shutdown()
    server_thread.join()
示例#2
0
def test_http_server_thread_port():
    queue = Queue()
    server_thread = HttpServerThread(
        RequestHandlerClass=QueuingRequestHandler.with_queue(queue),
        server_address=('', 12345))
    server_thread.start()
    port, host, fqdn = server_thread.server_address_info()
    if host == '0.0.0.0':
        host = '127.0.0.1'
    assert port == 12345
    url = 'http://{h}:{p}/foo/bar'.format(h=host, p=port)
    response = requests.get(url)
    response.raise_for_status()
    assert list(drain_queue(queue)) == ['/foo/bar']
    server_thread.shutdown()
    server_thread.join()
示例#3
0
def test_queuing_request_handler():
    queue = Queue()
    handle_request(QueuingRequestHandler.with_queue(queue), path="/foo/bar")
    assert list(drain_queue(queue)) == ['/foo/bar']