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
def test_invalid_fields(self): doc = Document(collection='test') doc.foo = InvalidField() doc.bar = InvalidField() doc.ham = Field() invalid_fields = doc.invalid_fields() for field_name in ('foo', 'bar'): assert field_name in invalid_fields invalid_fields.remove(field_name) assert len(invalid_fields) == 0