Exemple #1
0
 def test_is_valid_with_raises(self):
     field_obj = Field()
     field_obj.is_valid = lambda: False
     doc = Document(collection='test')
     doc.f = field_obj
     with pytest.raises(doc.DocumentInvalid):
         doc.is_valid(raises=True)
Exemple #2
0
 def test_is_valid(self):
     doc = Document(collection='test')
     doc.foo = Field()
     assert doc.is_valid() is True
     del doc.foo
     doc.foo = InvalidField()
     assert doc.is_valid() is False
Exemple #3
0
 def test_save_invalid(self):
     doc = Document(collection='test')
     doc.is_valid = lambda: False
     with pytest.raises(Document.DocumentInvalid):
         doc.save()