make the test simpler by using a new doc class

This commit is contained in:
Stefan Wojcik 2016-12-03 23:57:07 -05:00
parent c1a8b468c5
commit 38c36c0ba4

View File

@ -2200,23 +2200,18 @@ class QuerySetTest(unittest.TestCase):
def test_comment(self):
"""Make sure adding a comment to the query works."""
self.Person.drop_collection()
class User(Document):
age = IntField()
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')
.first())
ops = q.get_ops()
import pprint
pprint.pprint(ops)
self.assertEqual(len(ops), 1)
op = ops[0]
self.assertEqual(op['query']['$query'], {
'_cls': 'Person',
'age': {'$gte': 18}
})
self.assertEqual(op['query']['$comment'],
'looking for an adult')
self.assertEqual(op['query']['$query'], {'age': {'$gte': 18}})
self.assertEqual(op['query']['$comment'], 'looking for an adult')
def test_map_reduce(self):
"""Ensure map/reduce is both mapping and reducing.