Exemple #1
0
def test_build_response_error_1():
    response = Response()
    response.status_code = 0
    response.set_header('x-app', 'blargh!')
    response.set_body('{"hello": "world"}')

    with pytest.raises(Exception, match=r'Response not well formed'):
        response._build_response()
Exemple #2
0
def test_build_response_error_2():
    response = Response()
    response.status_code = 200
    response.headers = None
    response.set_body('{"hello": "world"}')

    with pytest.raises(Exception, match=r'Response not well formed'):
        response._build_response()
Exemple #3
0
def test_build_response():
    response = Response()
    response.set_status_code(404)
    response.set_header('x-app', 'blargh!')
    response.set_body('{"hello": "world"}')

    check = response._build_response()
    assert check['statusCode'] == 404
    assert check['body'] == '{"hello": "world"}'
    assert check['headers']['x-app'] == "blargh!"