Exemplo n.º 1
0
def test_error_handler_status_message():
    test_error = web.HTTPError(102, test_message, status_message=test_status)

    headers, response = test('GET',
                             handler=web.HTTPErrorHandler,
                             handler_args={'error': test_error})

    assert response[0] == test_error.code
    assert response[1] == test_status
    assert response[2] == test_message
Exemplo n.º 2
0
def test_error_handler():
    test_error = web.HTTPError(102)

    headers, response = test('GET',
                             handler=web.HTTPErrorHandler,
                             handler_args={'error': test_error})

    assert response[0] == test_error.code
    assert response[1] == web.status_messages[test_error.code]
    assert response[2] == str(
        test_error.code) + ' - ' + web.status_messages[test_error.code] + '\n'
Exemplo n.º 3
0
def test_error_headers():
    error_headers = web.HTTPHeaders()
    error_headers.set('Test', 'True')

    response, response_line, headers, body = test(
        web.DummyHandler, {'error': web.HTTPError(402, headers=error_headers)})

    assert response_line == 'HTTP/1.1 402 Payment Required'.encode(
        web.http_encoding)

    assert headers.get('Test') == 'True'
Exemplo n.º 4
0
 def __init__(self, request, response, groups, error=web.HTTPError(500)):
     FakeHTTPHandler.__init__(self, request, response, groups)
     self.error = error
Exemplo n.º 5
0
 def check_continue(self):
     raise web.HTTPError(417)
Exemplo n.º 6
0
        def respond(self):
            self.response.headers.set('Test', 'True')

            raise web.HTTPError(402)
Exemplo n.º 7
0
def test_http_error():
    response, response_line, headers, body = test(
        web.DummyHandler, {'error': web.HTTPError(402)})

    assert response_line == 'HTTP/1.1 402 Payment Required'.encode(
        web.http_encoding)