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

Method test_dynamic_fields_class

tests/fields/test_fields.py:2150–2171  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2148 assert x.items[0] in tuples
2149
2150 def test_dynamic_fields_class(self):
2151 class Doc2(Document):
2152 field_1 = StringField(db_field="f")
2153
2154 class Doc(Document):
2155 my_id = IntField(primary_key=True)
2156 embed_me = DynamicField(db_field="e")
2157 field_x = StringField(db_field="x")
2158
2159 Doc.drop_collection()
2160 Doc2.drop_collection()
2161
2162 doc2 = Doc2(field_1="hello")
2163 doc = Doc(my_id=1, embed_me=doc2, field_x="x")
2164 with pytest.raises(OperationError):
2165 doc.save()
2166
2167 doc2.save()
2168 doc.save()
2169
2170 doc = Doc.objects.get()
2171 assert doc.embed_me.field_1 == "hello"
2172
2173 def test_dynamic_fields_embedded_class(self):
2174 class Embed(EmbeddedDocument):

Callers

nothing calls this directly

Calls 5

Doc2Class · 0.85
drop_collectionMethod · 0.80
DocClass · 0.70
saveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected