make the test simpler by using a new doc class
This commit is contained in:
parent
c1a8b468c5
commit
38c36c0ba4
@ -2200,23 +2200,18 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_comment(self):
|
def test_comment(self):
|
||||||
"""Make sure adding a comment to the query works."""
|
"""Make sure adding a comment to the query works."""
|
||||||
self.Person.drop_collection()
|
class User(Document):
|
||||||
|
age = IntField()
|
||||||
|
|
||||||
with db_ops_tracker() as q:
|
with db_ops_tracker() as q:
|
||||||
adult = (self.Person.objects.filter(age__gte=18)
|
adult = (User.objects.filter(age__gte=18)
|
||||||
.comment('looking for an adult')
|
.comment('looking for an adult')
|
||||||
.first())
|
.first())
|
||||||
ops = q.get_ops()
|
ops = q.get_ops()
|
||||||
import pprint
|
|
||||||
pprint.pprint(ops)
|
|
||||||
self.assertEqual(len(ops), 1)
|
self.assertEqual(len(ops), 1)
|
||||||
op = ops[0]
|
op = ops[0]
|
||||||
self.assertEqual(op['query']['$query'], {
|
self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}})
|
||||||
'_cls': 'Person',
|
self.assertEqual(op['query']['$comment'], 'looking for an adult')
|
||||||
'age': {'$gte': 18}
|
|
||||||
})
|
|
||||||
self.assertEqual(op['query']['$comment'],
|
|
||||||
'looking for an adult')
|
|
||||||
|
|
||||||
def test_map_reduce(self):
|
def test_map_reduce(self):
|
||||||
"""Ensure map/reduce is both mapping and reducing.
|
"""Ensure map/reduce is both mapping and reducing.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user