Ticket #30120: query_test.diff

File query_test.diff, 1019 bytes (added by Claude Paroz, 5 years ago)

Failing test example

  • tests/aggregation_regress/tests.py

    diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
    index 274dc29d6d..5aa9decf3a 100644
    a b class AggregationTests(TestCase):  
    404404            Decimal('22.27'), places=2
    405405        )
    406406
    407     def test_distinct_conditional_aggregate(self):
     407    def test_distinct_conditional_aggregate_annotate(self):
    408408        self.assertEqual(
    409409            Book.objects.distinct().aggregate(test=Avg(Case(
    410410                When(price=Decimal('29.69'), then='pages'),
    class AggregationTests(TestCase):  
    412412            )))['test'],
    413413            325
    414414        )
     415        self.assertEqual(
     416            Author.objects.annotate(num_exp_books=Count(Case(
     417                When(book__price__gt=Decimal('25'), then=F('book__id'))
     418            ), distinct=True)).first().num_exp_books,
     419            1
     420        )
    415421
    416422    def test_conditional_aggregate_on_complex_condition(self):
    417423        self.assertEqual(
Back to Top