From 38c36c0ba40646d75ffb197892b17b6f32bb0fdf Mon Sep 17 00:00:00 2001 From: Stefan Wojcik Date: Sat, 3 Dec 2016 23:57:07 -0500 Subject: [PATCH] make the test simpler by using a new doc class --- tests/queryset/queryset.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/queryset/queryset.py b/tests/queryset/queryset.py index 29d21911..be877498 100644 --- a/tests/queryset/queryset.py +++ b/tests/queryset/queryset.py @@ -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.