示例#1
0
def test_missing_required_params_is_rejected(required_parm_name,
                                             create_valid_greeting_request):
    json_input = create_valid_greeting_request()
    del json_input[required_parm_name]
    with app.test_request_context("/", json=json_input):
        errors = validate_greeting(request)
        assert errors is not None
示例#2
0
def hello():
    errors = validate_greeting(request)
    if errors is not None:
        print(errors)
        raise InvalidUsage(errors)
    greetee = request.json.get("greetee", None)
    response = {"message": say_hello_to(greetee)}
    return jsonify(response)
示例#3
0
def test_valid_greetee_is_accepted(create_valid_greeting_request):
    json_input = create_valid_greeting_request(greetee="Tester")
    with app.test_request_context('/', json=json_input):
        errors = validate_greeting(request)
        assert errors is None
示例#4
0
def test_invalid_types_are_rejected(params, create_valid_greeting_request):
    json_input = create_valid_greeting_request(**params)
    with app.test_request_context('/', json=json_input):
        errors = validate_greeting(request)
        assert errors is not None