From 5384e4c47084a9b383875e98a99f30659e64c2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Thu, 30 Nov 2023 15:58:48 -0300 Subject: [PATCH] Use bulk_create to test ordered collections --- bookwyrm/tests/models/test_activitypub_mixin.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bookwyrm/tests/models/test_activitypub_mixin.py b/bookwyrm/tests/models/test_activitypub_mixin.py index 645a6546b..8af41ffbd 100644 --- a/bookwyrm/tests/models/test_activitypub_mixin.py +++ b/bookwyrm/tests/models/test_activitypub_mixin.py @@ -391,11 +391,13 @@ class ActivitypubMixins(TestCase): def test_to_ordered_collection_page(self, *_): """make sure the paged results of an ordered collection work""" self.assertEqual(PAGE_LENGTH, 15) - for number in range(0, 2 * PAGE_LENGTH): - models.Status.objects.create( + models.Status.objects.bulk_create( + models.Status( user=self.local_user, content=f"test status {number}", ) + for number in range(2 * PAGE_LENGTH) + ) page_1 = to_ordered_collection_page( models.Status.objects.all(), "http://fish.com/", page=1 ) @@ -416,13 +418,13 @@ class ActivitypubMixins(TestCase): def test_to_ordered_collection(self, *_): """convert a queryset into an ordered collection object""" self.assertEqual(PAGE_LENGTH, 15) - - for number in range(0, 2 * PAGE_LENGTH): - models.Status.objects.create( + models.Status.objects.bulk_create( + models.Status( user=self.local_user, content=f"test status {number}", ) - + for number in range(2 * PAGE_LENGTH) + ) MockSelf = namedtuple("Self", ("remote_id")) mock_self = MockSelf("")