def test_simple_dict_validation_list_len_works(): document = {"list_of_values": ["test1", 600]} schema = get_simple_dict_schema() v = Validator(schema, allow_list_missing=True) assert v.validate(document) is True assert v.errors == {}
def test_simple_dict_validation_list_len_breaks(): document = {"list_of_values": ["test1", 600]} schema = get_simple_dict_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"list_of_values": ["length of list should be 3, it is 2"]}
def test_simple_dict_validation_min_number_not_compliant(): document = {"list_of_values": ["test1", 400, "test2"]} schema = get_simple_dict_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"list_of_values": [{1: ["min value is 500"]}]}
def test_simple_dict_validation_breaks(): document = {"list_of_values": [40, 600, "test2"]} schema = get_simple_dict_schema() v = Validator(schema) assert v.validate(document) is False assert v.errors == {"list_of_values": [{0: ["must be of string type"]}]}
def test_simple_dict_validation_works(): document = {"list_of_values": ["test1", 600, "test2"]} schema = get_simple_dict_schema() v = Validator(schema) assert v.validate(document) is True assert v.errors == {}
def test_simple_dict_validation_works(): document = {"list_of_values": ["test1", 600, "test2"]} schema = get_simple_dict_schema() v = Validator(schema) assert v.normalized_as_dict(document) == { "hello": { 0: "test1", 1: 600, 2: "test2" } } assert v.errors == {}
def test_simple_dict_validation_works(): document = {"list_of_values": ["test1", 600, "test2"]} schema = get_simple_dict_schema() v = Validator(schema) o = v.normalized_as_object(document, callable_numbers=False) p = v.normalized_as_object(document, callable_numbers=True) assert o.hello[0] == "test1" assert o.hello[1] == 600 assert o.hello[2] == "test2" assert o["hello"][0] == "test1" assert o["hello"][1] == 600 assert o["hello"][2] == "test2" assert p.hello._0 == "test1" assert p.hello._1 == 600 assert p.hello._2 == "test2" assert p["hello"]["_0"] == "test1" assert p["hello"]["_1"] == 600 assert p["hello"]["_2"] == "test2"