Пример #1
0
 def test_additional_items_validate_failed(self):
     e = self.gen_class(self._type,
                        items=[String(), Integer()],
                        additional_items=String())()
     with pytest.raises(ValidationError) as exc_info:
         e.field = ["1", 1, 1]
     assert exc_info.value.args[0]["field"][2].code == "type"
Пример #2
0
 def test_additional_items_validate_success(self):
     e = self.gen_class(self._type,
                        items=[String(), Integer()],
                        additional_items=Boolean())(field=["1", 1, "1"])
     e.format(allow_coerce=True)
     assert e.field == ["1", 1, True]
Пример #3
0
 def test_additional_items_success(self):
     e = self.gen_class(self._type, items=[String(), Integer()])()
     e.field = ["1", 1, None]
     assert e.field == ["1", 1, None]
Пример #4
0
 def test_success_inner_type_many(self):
     e = self.gen_class(self._type, items=[String(), Integer()])()
     e.field = ["1", 1]
     assert e.field == ["1", 1]
Пример #5
0
 def test_failed_inner_type_many(self):
     e = self.gen_class(self._type, items=[String(), Integer()])()
     with pytest.raises(ValidationError) as exc_info:
         e.field = [1, "1"]
     assert exc_info.value.args[0]["field"][0].code == "type"
     assert exc_info.value.args[0]["field"][1].code == "type"
Пример #6
0
 def test_success_inner_type_one(self):
     e = self.gen_class(self._type, items=String())()
     e.field = ["1"]
     assert e.field == ["1"]
Пример #7
0
 def test_failed_inner_type_one(self):
     e = self.gen_class(self._type, items=String())()
     with pytest.raises(ValidationError) as exc_info:
         e.field = [1]
     assert exc_info.value.args[0]["field"][0].code == "type"