def test_simple_list_validation_list_len_works(): document = ["test1", 600] schema = get_simple_list_schema() v = Validator(schema, allow_list_missing=True) assert v.validate(document) is True assert v.errors == {}
def test_simple_list_validation_works(): document = ["test1", 600, "test2"] schema = get_simple_list_schema() v = Validator(schema) assert v.normalized(document) == ["test1", 600, "test2"] assert v.errors == {}
def test_simple_list_validation_list_len_breaks(): document = ["test1", 600] schema = get_simple_list_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"_schema": ["length of list should be 3, it is 2"]}
def test_simple_list_validation_min_number_not_compliant(): document = ["test1", 400, "test2"] schema = get_simple_list_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"_schema": [{1: ["min value is 500"]}]}
def test_simple_list_validation_breaks(): document = [40, 600, "test2"] schema = get_simple_list_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"_schema": [{0: ["must be of string type"]}]}
def test_simple_list_validation_works(): document = ["test1", 600, "test2"] schema = get_simple_list_schema() v = Validator(schema) assert v.validate(document) is True assert v.errors == {}
def test_simple_list_validation_works(): document = ["test1", 600, "test2"] schema = get_simple_list_schema() v = Validator(schema) o = v.normalized_as_object(document, callable_numbers=False) p = v.normalized_as_object(document, callable_numbers=True) assert o[0] == "test1" assert o[1] == 600 assert o[2] == "test2" assert p._0 == "test1" assert p._1 == 600 assert p._2 == "test2"