Ticket #16603: 16603-test.diff

File 16603-test.diff, 1022 bytes (added by Tim Graham, 9 years ago)
  • tests/aggregation_regress/tests.py

    diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
    index 44c0f0c..ff407d2 100644
    a b class AggregationTests(TestCase):  
    10201020            {'book__count__max': 2}
    10211021        )
    10221022
     1023    def test_reverse_filter(self):
     1024        # foreign key
     1025        qs = Author.objects.annotate(contact_book_pages=Sum('book_contact_set__pages'))
     1026        qs = qs.filter(name='Peter Norvig')
     1027        qs2 = qs.filter(book_contact_set__pages__gte=0)
     1028        self.assertEquals(qs[0].contact_book_pages, qs2[0].contact_book_pages)
     1029        # m2m
     1030        qs = Author.objects.annotate(pages_written=Sum('book__pages'))
     1031        qs = qs.filter(name='Peter Norvig')
     1032        qs2 = qs.filter(book__pubdate__lt='2011-01-01')
     1033        self.assertEquals(qs[0].pages_written, qs2[0].pages_written)
     1034
    10231035    def test_annotate_joins(self):
    10241036        """
    10251037        Test that the base table's join isn't promoted to LOUTER. This could
Back to Top