def test_missing_field_validation():
class Model(DynaModel):
class Table:
name = 'table'
hash_key = 'foo'
read = 1
write = 1
class Schema:
foo = String(required=True)
baz = String(required=True)
model = Model(foo='foo', partial=True)
with pytest.raises(ValidationError):
model.validate()
try:
model.validate()
except ValidationError as exc:
assert str(exc).startswith("Validation failed for schema ModelSchema. Errors: {'baz'")
评论列表
文章目录