Example #1
0
def test_error_5XX_status_code_message():
    response = Response()
    response.set_status_code(506)
    check = response.error_5XX('I\'m a variant!!!')
    assert check['statusCode'] == 506
    assert check['body'] == '{"message": "I\'m a variant!!!"}'
    assert check['headers']['Access-Control-Allow-Origin'] == '*'
Example #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!"
Example #3
0
def test_set_status_code_exp():
    response = Response()
    with pytest.raises(Exception):
        response.set_status_code(700)
Example #4
0
def test_set_status_code():
    response = Response()
    response.set_status_code(500)
    assert response.status_code == 500