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