Fixed assorted flake8 errors.

This commit is contained in:
Tim Graham 2013-10-11 07:25:14 -04:00
parent 695bc0d191
commit b67ab75e82
38 changed files with 92 additions and 73 deletions

View file

@ -1017,20 +1017,20 @@ class AggregationTests(TestCase):
tests aggregations with generic reverse relations
"""
b = Book.objects.get(name='Practical Django Projects')
ItemTag.objects.create(object_id=b.id, tag='intermediate',
content_type=ContentType.objects.get_for_model(b))
ItemTag.objects.create(object_id=b.id, tag='django',
content_type=ContentType.objects.get_for_model(b))
django_book = Book.objects.get(name='Practical Django Projects')
ItemTag.objects.create(object_id=django_book.id, tag='intermediate',
content_type=ContentType.objects.get_for_model(django_book))
ItemTag.objects.create(object_id=django_book.id, tag='django',
content_type=ContentType.objects.get_for_model(django_book))
# Assign a tag to model with same PK as the book above. If the JOIN
# used in aggregation doesn't have content type as part of the
# condition the annotation will also count the 'hi mom' tag for b.
wmpk = WithManualPK.objects.create(id=b.pk)
wmpk = WithManualPK.objects.create(id=django_book.pk)
ItemTag.objects.create(object_id=wmpk.id, tag='hi mom',
content_type=ContentType.objects.get_for_model(wmpk))
b = Book.objects.get(name__startswith='Paradigms of Artificial Intelligence')
ItemTag.objects.create(object_id=b.id, tag='intermediate',
content_type=ContentType.objects.get_for_model(b))
ai_book = Book.objects.get(name__startswith='Paradigms of Artificial Intelligence')
ItemTag.objects.create(object_id=ai_book.id, tag='intermediate',
content_type=ContentType.objects.get_for_model(ai_book))
self.assertEqual(Book.objects.aggregate(Count('tags')), {'tags__count': 3})
results = Book.objects.annotate(Count('tags')).order_by('-tags__count', 'name')