mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed E128 flake8 warnings in tests/.
This commit is contained in:
parent
df8d8d4292
commit
92053acbb9
148 changed files with 2073 additions and 2248 deletions
|
@ -1238,19 +1238,27 @@ class AggregationTests(TestCase):
|
|||
tests aggregations with generic reverse relations
|
||||
"""
|
||||
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))
|
||||
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=django_book.pk)
|
||||
ItemTag.objects.create(object_id=wmpk.id, tag='hi mom',
|
||||
content_type=ContentType.objects.get_for_model(wmpk))
|
||||
ItemTag.objects.create(
|
||||
object_id=wmpk.id, tag='hi mom',
|
||||
content_type=ContentType.objects.get_for_model(wmpk),
|
||||
)
|
||||
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))
|
||||
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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue