Skip to content

Commit 04a049f

Browse files
committed
fix tester
1 parent b8cf4c2 commit 04a049f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/queryset/test_queryset.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
queryset_manager,
2626
)
2727
from tests.utils import (
28+
requires_mongodb_gte_42,
2829
requires_mongodb_gte_44,
2930
requires_mongodb_lt_42,
3031
)
@@ -2217,6 +2218,19 @@ class BlogPost(Document):
22172218
post.reload()
22182219
assert post.tags == ["code", "mongodb"]
22192220

2221+
@requires_mongodb_gte_42
2222+
def test_aggregation_update(self):
2223+
"""Ensure that the 'aggregation_update' update works correctly."""
2224+
2225+
class BlogPost(Document):
2226+
slug = StringField()
2227+
tags = ListField(StringField())
2228+
2229+
BlogPost.drop_collection()
2230+
2231+
post = BlogPost(slug="test")
2232+
post.save()
2233+
22202234
BlogPost.objects(slug="test").update(
22212235
__raw__=[{"$set": {"slug": {"$concat": ["$slug", " ", "$slug"]}}}],
22222236
aggregation_update=True,

tests/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ def requires_mongodb_lt_42(func):
3737
return _decorated_with_ver_requirement(func, (4, 2), oper=operator.lt)
3838

3939

40+
def requires_mongodb_gte_42(func):
41+
return _decorated_with_ver_requirement(func, (4, 2), oper=operator.ge)
42+
43+
4044
def requires_mongodb_gte_44(func):
4145
return _decorated_with_ver_requirement(func, (4, 4), oper=operator.ge)
4246

0 commit comments

Comments
 (0)