Skip to content

Commit 38fdf26

Browse files
added tests for push and push_all
1 parent 9e80da7 commit 38fdf26

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/queryset/transform.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ class Doc(Document):
5151
update = transform.update(DicDoc, pull__dictField__test=doc)
5252
self.assertTrue(isinstance(update["$pull"]["dictField"]["test"], dict))
5353

54+
def test_transform_update_push(self):
55+
"""Ensure the differences in behvaior between 'push' and 'push_all'"""
56+
class BlogPost(Document):
57+
tags = ListField(StringField())
58+
59+
update = transform.update(BlogPost, push__tags=['mongo', 'db'])
60+
self.assertEqual(update, {'$push': {'tags': ['mongo', 'db']}})
61+
62+
update = transform.update(BlogPost, push_all__tags=['mongo', 'db'])
63+
self.assertEqual(update, {'$push': {'tags': {'$each': ['mongo', 'db']}}})
64+
5465
def test_query_field_name(self):
5566
"""Ensure that the correct field name is used when querying.
5667
"""

0 commit comments

Comments
 (0)