def test_using_default_value_that_is_falsely_evaluated(self): r = RequestSchema(querystring={optional('param', 0): Use(int)}) assert r.validate_querystring({}) == {'param': 0}
def test_schemas_in_constructor_of_request_schema(self): r = RequestSchema(url={'param': Use(int)}) assert r.validate_url({'param': '123'}) == {'param': 123} assert r.describe_url['param'] == ''
def test_schemas_in_constructor_of_request_schema(self): r = RequestSchema(url={'param': Use(int)}) assert r.validate_url({'param': '123'}) == {'param': 123} params = r.url_params() assert params[0].name == 'param' assert params[0].description == ''
def test_using_default_value_of_optional_param(self): r = RequestSchema(querystring={optional('param', 1): Use(int)}) assert r.validate_querystring({}) == {'param': 1}
def test_optional_without_default_value(self): r = RequestSchema(querystring={optional('param'): Use(int)}) assert r.validate_querystring({}) == {}
def test_default_value_is_the_final_value_to_be_used(self): r = RequestSchema(querystring={optional('param', 'blank'): Use(int)}) assert r.validate_querystring({}) == {'param': 'blank'}