Used QuerySet.bulk_create() in the SearchFilterToManyTests instead of multiple Queryset.create()

This commit is contained in:
oliver 2018-11-08 11:57:12 +09:00
parent bf9533ae37
commit a7ba1f7d12

View File

@ -283,13 +283,15 @@ class SearchFilterToManyTests(TestCase):
b1 = Blog.objects.create(name='Blog 1') b1 = Blog.objects.create(name='Blog 1')
b2 = Blog.objects.create(name='Blog 2') b2 = Blog.objects.create(name='Blog 2')
# Multiple entries on Lennon published in 1979 - distinct should deduplicate Entry.objects.bulk_create([
Entry.objects.create(blog=b1, headline='Something about Lennon', pub_date=datetime.date(1979, 1, 1)) # Multiple entries on Lennon published in 1979 - distinct should deduplicate
Entry.objects.create(blog=b1, headline='Another thing about Lennon', pub_date=datetime.date(1979, 6, 1)) Entry(blog=b1, headline='Something about Lennon', pub_date=datetime.date(1979, 1, 1)),
Entry(blog=b1, headline='Another thing about Lennon', pub_date=datetime.date(1979, 6, 1)),
# Entry on Lennon *and* a separate entry in 1979 - should not match # Entry on Lennon *and* a separate entry in 1979 - should not match
Entry.objects.create(blog=b2, headline='Something unrelated', pub_date=datetime.date(1979, 1, 1)) Entry(blog=b2, headline='Something unrelated', pub_date=datetime.date(1979, 1, 1)),
Entry.objects.create(blog=b2, headline='Retrospective on Lennon', pub_date=datetime.date(1990, 6, 1)) Entry(blog=b2, headline='Retrospective on Lennon', pub_date=datetime.date(1990, 6, 1)),
])
def test_multiple_filter_conditions(self): def test_multiple_filter_conditions(self):
class SearchListView(generics.ListAPIView): class SearchListView(generics.ListAPIView):