Пример #1
0
def test_request_url_from_server_address():
    request_handler = mock.Mock()
    request_handler.server.scheme = 'http'
    request_handler.server.server_address = ('localhost', '8000')
    request_handler.path = '/demo'
    request_handler.headers = MockHTTPMessage()

    request = Request(request_handler)
    assert request.url == 'http://localhost:8000/demo'
    assert isinstance(request.url, str)
Пример #2
0
def test_request_url_from_host_header():
    request_handler = mock.Mock()
    request_handler.server.scheme = 'http'
    request_handler.server.server_address = ('localhost', '8000')
    request_handler.path = '/demo'
    request_handler.headers = MockHTTPMessage({'host': ['web-platform.test:8001']})

    request = Request(request_handler)
    assert request.url == 'http://web-platform.test:8001/demo'
    assert isinstance(request.url, str)