make the test simpler by using a new doc class
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user