Added exec_js and sum functions to QuerySet

This commit is contained in:
Harry Marr
2009-12-30 15:14:18 +00:00
parent 90e5e5dfa9
commit 2cc68b46ad
2 changed files with 36 additions and 4 deletions

View File

@@ -214,6 +214,15 @@ class QuerySetTest(unittest.TestCase):
BlogPost.drop_collection()
def test_sum(self):
"""Ensure that field can be summed over correctly.
"""
ages = [23, 54, 12, 94, 27]
for i, age in enumerate(ages):
self.Person(name='test%s' % i, age=age).save()
self.assertEqual(int(self.Person.objects.sum('age')), sum(ages))
def test_custom_manager(self):
"""Ensure that custom QuerySetManager instances work as expected.
"""