MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / test_complex_field_required

Method test_complex_field_required

tests/fields/test_fields.py:1068–1088  ·  view source on GitHub ↗

Ensure required cant be None / Empty.

(self)

Source from the content-addressed store, hash-verified

1066 e.save()
1067
1068 def test_complex_field_required(self):
1069 """Ensure required cant be None / Empty."""
1070
1071 class Simple(Document):
1072 mapping = ListField(required=True)
1073
1074 Simple.drop_collection()
1075
1076 e = Simple()
1077 e.mapping = []
1078 with pytest.raises(ValidationError):
1079 e.save()
1080
1081 class Simple(Document):
1082 mapping = DictField(required=True)
1083
1084 Simple.drop_collection()
1085 e = Simple()
1086 e.mapping = {}
1087 with pytest.raises(ValidationError):
1088 e.save()
1089
1090 def test_complex_field_same_value_not_changed(self):
1091 """If a complex field is set to the same value, it should not

Callers

nothing calls this directly

Calls 3

drop_collectionMethod · 0.80
SimpleClass · 0.70
saveMethod · 0.45

Tested by

no test coverage detected