예제 #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()
예제 #2
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!"
예제 #3
0
def test_set_header():
    response = Response()
    response.set_header('x-api', 'some_random_stuff')
    assert response.headers['x-api'] == 'some_random_stuff'
예제 #4
0
def test_set_header_missing_key():
    response = Response()
    with pytest.raises(Exception, match=r"a header key"):
        response.set_header(None, 'some_random_stuff')