(self)
| 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): |
nothing calls this directly
no test coverage detected