summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorÉtienne Beaulé <beauleetienne0@gmail.com>2019-07-30 20:08:55 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-31 11:22:50 +0200
commit5f24e7158e1d5a7e40fa0ae270639f6a171bb18e (patch)
tree36b249e5a101df5f3494be9000db857e5af9c3d1 /tests/aggregation
parentcb3c2da12858004c805fc511a9c2eb0f91fb73c7 (diff)
Fixed #30665 -- Added support for distinct argument to Avg() and Sum().
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 7e0436cdfc..0f799c4bc3 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -401,8 +401,14 @@ class AggregateTestCase(TestCase):
self.assertEqual(aggs['distinct_ratings'], 4)
def test_distinct_on_aggregate(self):
- books = Book.objects.aggregate(ratings=Count('rating', distinct=True))
- self.assertEqual(books['ratings'], 4)
+ for aggregate, expected_result in (
+ (Avg, 4.125),
+ (Count, 4),
+ (Sum, 16.5),
+ ):
+ with self.subTest(aggregate=aggregate.__name__):
+ books = Book.objects.aggregate(ratings=aggregate('rating', distinct=True))
+ self.assertEqual(books['ratings'], expected_result)
def test_non_grouped_annotation_not_in_group_by(self):
"""