Пример #1
0
def test_route_with_no_type_hints_argument():

    def return_input_string(input_string):
        return input_string

    test_app = create_test_app("/foo", return_input_string)
    assert json.loads(test_app.get("/foo?input_string=testme").data.decode("UTF-8")) == {
        "success": True,
        "result": "testme"
    }
Пример #2
0
def test_route_yaml():

    def return_input_string(input_string):
        return input_string

    test_app = create_test_app("/foo", return_input_string)
    resp = test_app.get("/foo?input_string=testme", headers={
        "content-type": "application/yaml"
    })
    assert "success: true" in resp.data.decode("UTF-8")
    assert yaml.load(resp.data.decode("UTF-8")) == {
        "success": True,
        "result": "testme"
    }
Пример #3
0
def test_route_with_no_type_hints(ret_val):
    """
    with no type hinting, the serializer should just try to serialize
    to json with json.dumps
    """

    def return_foo():
        return ret_val

    test_app = create_test_app("/foo", return_foo)
    assert json.loads(test_app.get("/foo").data.decode("UTF-8")) == {
        "success": True,
        "result": ret_val
    }