Fixed incorrect $pull test

This commit is contained in:
Harry Marr 2010-08-30 19:59:49 +01:00
parent 17642c8a8c
commit 69012e8ad1

View File

@ -681,23 +681,17 @@ class QuerySetTest(unittest.TestCase):
def test_update_pull(self): def test_update_pull(self):
"""Ensure that the 'pull' update operation works correctly. """Ensure that the 'pull' update operation works correctly.
""" """
class Comment(EmbeddedDocument):
content = StringField()
class BlogPost(Document): class BlogPost(Document):
slug = StringField() slug = StringField()
comments = ListField(EmbeddedDocumentField(Comment)) tags = ListField(StringField())
comment1 = Comment(content="test1") post = BlogPost(slug="test", tags=['code', 'mongodb', 'code'])
comment2 = Comment(content="test2")
post = BlogPost(slug="test", comments=[comment1, comment2])
post.save() post.save()
self.assertTrue(comment2 in post.comments)
BlogPost.objects(slug="test").update(pull__comments__content="test2") BlogPost.objects(slug="test").update(pull__tags="code")
post.reload() post.reload()
self.assertTrue(comment2 not in post.comments) self.assertTrue('code' not in post.tags)
self.assertEqual(len(post.tags), 1)
def test_order_by(self): def test_order_by(self):
"""Ensure that QuerySets may be ordered. """Ensure that QuerySets may be ordered.