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

Method test_pull_nested

tests/queryset/test_queryset.py:2405–2425  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2403 assert [parent_1, parent_2] == item.parents
2404
2405 def test_pull_nested(self):
2406 class Collaborator(EmbeddedDocument):
2407 user = StringField()
2408
2409 def __unicode__(self):
2410 return "%s" % self.user
2411
2412 class Site(Document):
2413 name = StringField(max_length=75, unique=True, required=True)
2414 collaborators = ListField(EmbeddedDocumentField(Collaborator))
2415
2416 Site.drop_collection()
2417
2418 c = Collaborator(user="Esteban")
2419 s = Site(name="test", collaborators=[c]).save()
2420
2421 Site.objects(id=s.id).update_one(pull__collaborators__user="Esteban")
2422 assert Site.objects.first().collaborators == []
2423
2424 with pytest.raises(InvalidQueryError):
2425 Site.objects(id=s.id).update_one(pull_all__collaborators__user=["Ross"])
2426
2427 def test_pull_from_nested_embedded(self):
2428 class User(EmbeddedDocument):

Callers

nothing calls this directly

Calls 7

CollaboratorClass · 0.85
drop_collectionMethod · 0.80
update_oneMethod · 0.80
SiteClass · 0.70
saveMethod · 0.45
objectsMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected