(self)
| 5308 | assert result == {"_id": user.id, "name": "User", "age": 50} |
| 5309 | |
| 5310 | def test_no_dereference(self): |
| 5311 | class Organization(Document): |
| 5312 | name = StringField() |
| 5313 | |
| 5314 | class User(Document): |
| 5315 | name = StringField() |
| 5316 | organization = ReferenceField(Organization) |
| 5317 | |
| 5318 | User.drop_collection() |
| 5319 | Organization.drop_collection() |
| 5320 | |
| 5321 | whitehouse = Organization(name="White House").save() |
| 5322 | User(name="Bob Dole", organization=whitehouse).save() |
| 5323 | |
| 5324 | qs = User.objects() |
| 5325 | qs_user = qs.first() |
| 5326 | |
| 5327 | assert isinstance(qs.first().organization, Organization) |
| 5328 | |
| 5329 | user = qs.no_dereference().first() |
| 5330 | assert isinstance(user.organization, DBRef) |
| 5331 | |
| 5332 | assert isinstance(qs_user.organization, Organization) |
| 5333 | assert isinstance(qs.first().organization, Organization) |
| 5334 | |
| 5335 | def test_no_dereference_internals(self): |
| 5336 | # Test the internals on which queryset.no_dereference relies on |
nothing calls this directly
no test coverage detected