def test_validator_wrong():
from mongoengine import Document, StringField
class Test(Document):
parent = StringField()
with pytest.raises(Exception) as e_info:
Options('TestSchema', {'model': Test, 'validator': True})
assert str(e_info.value) == "'validator' attribute must be callable."
with pytest.raises(Exception) as e_info:
Options('TestSchema', {'model': Test, 'validator': lambda x: x})
assert str(e_info.value) == ("The 'validator' attribute must be a callable that accepts four arguments: "
"model, fields, query, special_params")
评论列表
文章目录