Ticket #27632: test_annotation_with_value.diff

File test_annotation_with_value.diff, 961 bytes (added by Mariusz Felisiak, 7 years ago)
  • tests/aggregation_regress/tests.py

    diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
    index 59a40c7..cfa8b1a 100644
    a b class AggregationTests(TestCase):  
    107107        for attr, value in six.iteritems(kwargs):
    108108            self.assertEqual(getattr(obj, attr), value)
    109109
     110    def test_annotation_with_value(self):
     111        values = (
     112            Book.objects
     113            .filter(name='Practical Django Projects')
     114            .annotate(discount_price=F('price') * 0.75)
     115            .values('discount_price')
     116            .annotate(sum_discount=Sum('discount_price'))
     117        )
     118        self.assertEqual(
     119            values,
     120            {'discount_price': Decimal('22.2675'), 'sum_discount': Decimal('22.2675')},
     121        )
     122
    110123    def test_aggregates_in_where_clause(self):
    111124        """
    112125        Regression test for #12822: DatabaseError: aggregates not allowed in
Back to Top