Ticket #12822: more-aggregation-unittests.diff

File more-aggregation-unittests.diff, 836 bytes (added by Mathieu Pillard, 14 years ago)

Unit test (without the hardcoded id this time)

  • modeltests/aggregation/models.py

     
    366366>>> list(qs) == [(Decimal('29.69'), 2), (Decimal('23.09'), 1), (Decimal('30'), 1), (Decimal('75'), 1), (Decimal('82.8'), 1)]
    367367True
    368368
     369>>> b = Book(name='AnotherBook', pages=1, isbn='42', rating=3.5, price=Decimal("100"), publisher_id=1, contact_id=1, pubdate=date(2010,3,8))
     370>>> b.save()
     371
     372>>> qs = Book.objects.values('contact').annotate(Max('id')).order_by( 'contact').values_list('id__max', flat=True)
     373>>> result_without_list = Book.objects.filter(id__in=qs)
     374>>> result_with_list = Book.objects.filter(id__in=list(qs))
     375>>> len(result_without_list) == len(result_with_list) == 5
     376True
     377
    369378"""}
Back to Top