From 1b9e0546e64dd0306c3389034fa0df8127d22e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Sun, 17 Mar 2024 19:46:30 -0300 Subject: [PATCH] Bracket-wrap calls to `patch()` for better readability --- .../tests/activitypub/test_base_activity.py | 8 +- bookwyrm/tests/activitypub/test_note.py | 8 +- .../activitystreams/test_abstractstream.py | 16 ++- .../tests/activitystreams/test_booksstream.py | 8 +- .../tests/activitystreams/test_homestream.py | 8 +- .../tests/activitystreams/test_localstream.py | 8 +- .../tests/activitystreams/test_signals.py | 8 +- bookwyrm/tests/activitystreams/test_tasks.py | 8 +- .../connectors/test_inventaire_connector.py | 13 ++- .../tests/importers/test_calibre_import.py | 8 +- .../tests/importers/test_goodreads_import.py | 8 +- bookwyrm/tests/importers/test_importer.py | 8 +- .../importers/test_librarything_import.py | 8 +- .../importers/test_openlibrary_import.py | 8 +- .../tests/importers/test_storygraph_import.py | 8 +- bookwyrm/tests/lists_stream/test_signals.py | 8 +- bookwyrm/tests/lists_stream/test_stream.py | 8 +- bookwyrm/tests/lists_stream/test_tasks.py | 15 ++- .../management/test_populate_lists_streams.py | 8 +- .../tests/management/test_populate_streams.py | 17 +-- .../tests/models/test_activitypub_mixin.py | 8 +- bookwyrm/tests/models/test_automod.py | 8 +- bookwyrm/tests/models/test_base_model.py | 8 +- .../tests/models/test_bookwyrm_export_job.py | 18 ++- .../tests/models/test_bookwyrm_import_job.py | 110 +++++++++++------- bookwyrm/tests/models/test_group.py | 22 ++-- bookwyrm/tests/models/test_import_model.py | 8 +- bookwyrm/tests/models/test_list.py | 8 +- bookwyrm/tests/models/test_notification.py | 24 ++-- .../tests/models/test_readthrough_model.py | 8 +- .../tests/models/test_relationship_models.py | 8 +- bookwyrm/tests/models/test_shelf_model.py | 8 +- bookwyrm/tests/models/test_site.py | 8 +- bookwyrm/tests/models/test_status_model.py | 8 +- bookwyrm/tests/models/test_user_model.py | 37 +++--- .../templatetags/test_book_display_tags.py | 8 +- .../tests/templatetags/test_feed_page_tags.py | 8 +- .../tests/templatetags/test_interaction.py | 8 +- .../test_notification_page_tags.py | 8 +- .../tests/templatetags/test_rating_tags.py | 8 +- .../tests/templatetags/test_shelf_tags.py | 8 +- .../tests/templatetags/test_status_display.py | 8 +- bookwyrm/tests/templatetags/test_utilities.py | 8 +- bookwyrm/tests/test_context_processors.py | 8 +- bookwyrm/tests/test_emailing.py | 8 +- bookwyrm/tests/test_preview_images.py | 24 ++-- bookwyrm/tests/test_signing.py | 8 +- bookwyrm/tests/test_suggested_users.py | 8 +- .../tests/views/admin/test_announcements.py | 8 +- bookwyrm/tests/views/admin/test_automod.py | 8 +- bookwyrm/tests/views/admin/test_celery.py | 8 +- bookwyrm/tests/views/admin/test_dashboard.py | 8 +- .../tests/views/admin/test_email_blocks.py | 8 +- .../tests/views/admin/test_email_config.py | 8 +- bookwyrm/tests/views/admin/test_federation.py | 8 +- bookwyrm/tests/views/admin/test_imports.py | 8 +- .../tests/views/admin/test_ip_blocklist.py | 8 +- .../tests/views/admin/test_link_domains.py | 8 +- bookwyrm/tests/views/admin/test_reports.py | 8 +- bookwyrm/tests/views/admin/test_site.py | 8 +- bookwyrm/tests/views/admin/test_themes.py | 8 +- bookwyrm/tests/views/admin/test_user_admin.py | 8 +- bookwyrm/tests/views/books/test_book.py | 8 +- bookwyrm/tests/views/books/test_edit_book.py | 8 +- bookwyrm/tests/views/books/test_editions.py | 8 +- bookwyrm/tests/views/books/test_links.py | 5 +- bookwyrm/tests/views/imports/test_import.py | 8 +- .../tests/views/imports/test_import_review.py | 8 +- .../views/imports/test_import_troubleshoot.py | 8 +- .../tests/views/imports/test_user_import.py | 8 +- bookwyrm/tests/views/inbox/test_inbox.py | 8 +- bookwyrm/tests/views/inbox/test_inbox_add.py | 8 +- .../tests/views/inbox/test_inbox_announce.py | 8 +- .../tests/views/inbox/test_inbox_block.py | 17 ++- .../tests/views/inbox/test_inbox_create.py | 16 ++- .../tests/views/inbox/test_inbox_delete.py | 8 +- .../tests/views/inbox/test_inbox_follow.py | 8 +- bookwyrm/tests/views/inbox/test_inbox_like.py | 8 +- .../tests/views/inbox/test_inbox_remove.py | 15 ++- .../tests/views/inbox/test_inbox_update.py | 15 ++- bookwyrm/tests/views/landing/test_invite.py | 8 +- bookwyrm/tests/views/landing/test_landing.py | 8 +- bookwyrm/tests/views/landing/test_login.py | 8 +- bookwyrm/tests/views/landing/test_password.py | 8 +- bookwyrm/tests/views/landing/test_register.py | 8 +- bookwyrm/tests/views/lists/test_curate.py | 15 ++- bookwyrm/tests/views/lists/test_embed.py | 15 ++- bookwyrm/tests/views/lists/test_list.py | 33 ++++-- bookwyrm/tests/views/lists/test_list_item.py | 15 ++- bookwyrm/tests/views/lists/test_lists.py | 46 +++++--- .../tests/views/preferences/test_block.py | 18 +-- .../views/preferences/test_change_password.py | 8 +- .../views/preferences/test_delete_user.py | 15 ++- .../tests/views/preferences/test_edit_user.py | 15 ++- .../tests/views/preferences/test_export.py | 5 +- .../views/preferences/test_export_user.py | 5 +- .../views/preferences/test_two_factor_auth.py | 13 ++- bookwyrm/tests/views/shelf/test_shelf.py | 8 +- .../tests/views/shelf/test_shelf_actions.py | 8 +- bookwyrm/tests/views/test_annual_summary.py | 8 +- bookwyrm/tests/views/test_author.py | 8 +- bookwyrm/tests/views/test_directory.py | 8 +- bookwyrm/tests/views/test_discover.py | 8 +- bookwyrm/tests/views/test_feed.py | 8 +- bookwyrm/tests/views/test_follow.py | 24 ++-- bookwyrm/tests/views/test_get_started.py | 8 +- bookwyrm/tests/views/test_goal.py | 8 +- bookwyrm/tests/views/test_group.py | 8 +- bookwyrm/tests/views/test_hashtag.py | 36 +++--- bookwyrm/tests/views/test_helpers.py | 8 +- bookwyrm/tests/views/test_interaction.py | 8 +- bookwyrm/tests/views/test_isbn.py | 8 +- bookwyrm/tests/views/test_notifications.py | 15 ++- bookwyrm/tests/views/test_outbox.py | 8 +- bookwyrm/tests/views/test_reading.py | 8 +- bookwyrm/tests/views/test_readthrough.py | 8 +- bookwyrm/tests/views/test_report.py | 15 ++- bookwyrm/tests/views/test_rss_feed.py | 8 +- bookwyrm/tests/views/test_search.py | 15 ++- bookwyrm/tests/views/test_status.py | 16 ++- bookwyrm/tests/views/test_updates.py | 34 +++--- bookwyrm/tests/views/test_user.py | 16 +-- bookwyrm/tests/views/test_wellknown.py | 8 +- 123 files changed, 883 insertions(+), 559 deletions(-) diff --git a/bookwyrm/tests/activitypub/test_base_activity.py b/bookwyrm/tests/activitypub/test_base_activity.py index a0d10019f..8f2cd7fb2 100644 --- a/bookwyrm/tests/activitypub/test_base_activity.py +++ b/bookwyrm/tests/activitypub/test_base_activity.py @@ -31,9 +31,11 @@ class BaseActivity(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we're probably going to re-use this so why copy/paste""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitypub/test_note.py b/bookwyrm/tests/activitypub/test_note.py index fd5467f01..65502c70a 100644 --- a/bookwyrm/tests/activitypub/test_note.py +++ b/bookwyrm/tests/activitypub/test_note.py @@ -13,9 +13,11 @@ class Note(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create a shared user""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitystreams/test_abstractstream.py b/bookwyrm/tests/activitystreams/test_abstractstream.py index 83985efdc..acdd5529c 100644 --- a/bookwyrm/tests/activitystreams/test_abstractstream.py +++ b/bookwyrm/tests/activitystreams/test_abstractstream.py @@ -18,9 +18,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) @@ -105,9 +107,11 @@ class Activitystreams(TestCase): privacy="direct", book=self.book, ) - with patch("bookwyrm.activitystreams.r.set"), patch( - "bookwyrm.activitystreams.r.delete" - ), patch("bookwyrm.activitystreams.ActivityStream.get_store") as redis_mock: + with ( + patch("bookwyrm.activitystreams.r.set"), + patch("bookwyrm.activitystreams.r.delete"), + patch("bookwyrm.activitystreams.ActivityStream.get_store") as redis_mock, + ): redis_mock.return_value = [status.id, status2.id] result = self.test_stream.get_activity_stream(self.local_user) self.assertEqual(result.count(), 2) diff --git a/bookwyrm/tests/activitystreams/test_booksstream.py b/bookwyrm/tests/activitystreams/test_booksstream.py index 71d7ce531..eb61cc203 100644 --- a/bookwyrm/tests/activitystreams/test_booksstream.py +++ b/bookwyrm/tests/activitystreams/test_booksstream.py @@ -17,9 +17,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitystreams/test_homestream.py b/bookwyrm/tests/activitystreams/test_homestream.py index 3312f20ee..0baf1d1b8 100644 --- a/bookwyrm/tests/activitystreams/test_homestream.py +++ b/bookwyrm/tests/activitystreams/test_homestream.py @@ -15,9 +15,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitystreams/test_localstream.py b/bookwyrm/tests/activitystreams/test_localstream.py index f4ca13395..92ec2b069 100644 --- a/bookwyrm/tests/activitystreams/test_localstream.py +++ b/bookwyrm/tests/activitystreams/test_localstream.py @@ -15,9 +15,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitystreams/test_signals.py b/bookwyrm/tests/activitystreams/test_signals.py index db16a0081..b9fb75ade 100644 --- a/bookwyrm/tests/activitystreams/test_signals.py +++ b/bookwyrm/tests/activitystreams/test_signals.py @@ -17,9 +17,11 @@ class ActivitystreamsSignals(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/activitystreams/test_tasks.py b/bookwyrm/tests/activitystreams/test_tasks.py index 39a240e92..cf2ee40e6 100644 --- a/bookwyrm/tests/activitystreams/test_tasks.py +++ b/bookwyrm/tests/activitystreams/test_tasks.py @@ -10,9 +10,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/connectors/test_inventaire_connector.py b/bookwyrm/tests/connectors/test_inventaire_connector.py index c4ea1a595..874d64862 100644 --- a/bookwyrm/tests/connectors/test_inventaire_connector.py +++ b/bookwyrm/tests/connectors/test_inventaire_connector.py @@ -212,11 +212,14 @@ class Inventaire(TestCase): json={"entities": {}}, ) data = {"uri": "blah"} - with patch( - "bookwyrm.connectors.inventaire.Connector.load_edition_data" - ) as loader_mock, patch( - "bookwyrm.connectors.inventaire.Connector.get_book_data" - ) as getter_mock: + with ( + patch( + "bookwyrm.connectors.inventaire.Connector.load_edition_data" + ) as loader_mock, + patch( + "bookwyrm.connectors.inventaire.Connector.get_book_data" + ) as getter_mock, + ): loader_mock.return_value = {"uris": ["hello"]} self.connector.get_edition_from_work_data(data) self.assertTrue(getter_mock.called) diff --git a/bookwyrm/tests/importers/test_calibre_import.py b/bookwyrm/tests/importers/test_calibre_import.py index d549a75ed..6bfa754af 100644 --- a/bookwyrm/tests/importers/test_calibre_import.py +++ b/bookwyrm/tests/importers/test_calibre_import.py @@ -25,9 +25,11 @@ class CalibreImport(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/importers/test_goodreads_import.py b/bookwyrm/tests/importers/test_goodreads_import.py index 0b5fd5e2d..deb41a1df 100644 --- a/bookwyrm/tests/importers/test_goodreads_import.py +++ b/bookwyrm/tests/importers/test_goodreads_import.py @@ -32,9 +32,11 @@ class GoodreadsImport(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/importers/test_importer.py b/bookwyrm/tests/importers/test_importer.py index eb3041dc6..494d28ad0 100644 --- a/bookwyrm/tests/importers/test_importer.py +++ b/bookwyrm/tests/importers/test_importer.py @@ -35,9 +35,11 @@ class GenericImporter(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/importers/test_librarything_import.py b/bookwyrm/tests/importers/test_librarything_import.py index c2fe7a9a8..ba86721de 100644 --- a/bookwyrm/tests/importers/test_librarything_import.py +++ b/bookwyrm/tests/importers/test_librarything_import.py @@ -34,9 +34,11 @@ class LibrarythingImport(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mmai", "mmai@mmai.mmai", "password", local=True ) diff --git a/bookwyrm/tests/importers/test_openlibrary_import.py b/bookwyrm/tests/importers/test_openlibrary_import.py index 2712930d9..e0e6135c9 100644 --- a/bookwyrm/tests/importers/test_openlibrary_import.py +++ b/bookwyrm/tests/importers/test_openlibrary_import.py @@ -32,9 +32,11 @@ class OpenLibraryImport(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/importers/test_storygraph_import.py b/bookwyrm/tests/importers/test_storygraph_import.py index edc484629..180cd8ad4 100644 --- a/bookwyrm/tests/importers/test_storygraph_import.py +++ b/bookwyrm/tests/importers/test_storygraph_import.py @@ -32,9 +32,11 @@ class StorygraphImport(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """populate database""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/lists_stream/test_signals.py b/bookwyrm/tests/lists_stream/test_signals.py index 51f0709b0..923d19a2f 100644 --- a/bookwyrm/tests/lists_stream/test_signals.py +++ b/bookwyrm/tests/lists_stream/test_signals.py @@ -11,9 +11,11 @@ class ListsStreamSignals(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """database setup""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/lists_stream/test_stream.py b/bookwyrm/tests/lists_stream/test_stream.py index 6dd6a1c8e..fcac04d19 100644 --- a/bookwyrm/tests/lists_stream/test_stream.py +++ b/bookwyrm/tests/lists_stream/test_stream.py @@ -18,9 +18,11 @@ class ListsStream(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """database setup""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/lists_stream/test_tasks.py b/bookwyrm/tests/lists_stream/test_tasks.py index 18ddecf18..fe3cb319d 100644 --- a/bookwyrm/tests/lists_stream/test_tasks.py +++ b/bookwyrm/tests/lists_stream/test_tasks.py @@ -13,9 +13,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """database setup""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) @@ -36,9 +38,10 @@ class Activitystreams(TestCase): inbox="https://example.com/users/rat/inbox", outbox="https://example.com/users/rat/outbox", ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): self.list = models.List.objects.create( user=self.local_user, name="hi", privacy="public" ) diff --git a/bookwyrm/tests/management/test_populate_lists_streams.py b/bookwyrm/tests/management/test_populate_lists_streams.py index 5990da4e3..f098c2b11 100644 --- a/bookwyrm/tests/management/test_populate_lists_streams.py +++ b/bookwyrm/tests/management/test_populate_lists_streams.py @@ -15,9 +15,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need some stuff""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/management/test_populate_streams.py b/bookwyrm/tests/management/test_populate_streams.py index 4d6bf688f..034222b29 100644 --- a/bookwyrm/tests/management/test_populate_streams.py +++ b/bookwyrm/tests/management/test_populate_streams.py @@ -13,9 +13,11 @@ class Activitystreams(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need some stuff""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) @@ -53,11 +55,10 @@ class Activitystreams(TestCase): user=self.local_user, content="hi", book=self.book ) - with patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ) as redis_mock, patch( - "bookwyrm.lists_stream.populate_lists_task.delay" - ) as list_mock: + with ( + patch("bookwyrm.activitystreams.populate_stream_task.delay") as redis_mock, + patch("bookwyrm.lists_stream.populate_lists_task.delay") as list_mock, + ): populate_streams() self.assertEqual(redis_mock.call_count, 6) # 2 users x 3 streams self.assertEqual(list_mock.call_count, 2) # 2 users diff --git a/bookwyrm/tests/models/test_activitypub_mixin.py b/bookwyrm/tests/models/test_activitypub_mixin.py index 2f6fad76d..b59088f91 100644 --- a/bookwyrm/tests/models/test_activitypub_mixin.py +++ b/bookwyrm/tests/models/test_activitypub_mixin.py @@ -29,9 +29,11 @@ class ActivitypubMixins(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """shared data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_automod.py b/bookwyrm/tests/models/test_automod.py index 1ad139886..ed3133cdc 100644 --- a/bookwyrm/tests/models/test_automod.py +++ b/bookwyrm/tests/models/test_automod.py @@ -17,9 +17,11 @@ class AutomodModel(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/models/test_base_model.py b/bookwyrm/tests/models/test_base_model.py index f1f465b73..d0e441cef 100644 --- a/bookwyrm/tests/models/test_base_model.py +++ b/bookwyrm/tests/models/test_base_model.py @@ -15,9 +15,11 @@ class BaseModel(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """shared data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_bookwyrm_export_job.py b/bookwyrm/tests/models/test_bookwyrm_export_job.py index b5f2520a9..be6bda3cc 100644 --- a/bookwyrm/tests/models/test_bookwyrm_export_job.py +++ b/bookwyrm/tests/models/test_bookwyrm_export_job.py @@ -16,16 +16,14 @@ class BookwyrmExport(TestCase): def setUp(self): """lots of stuff to set up for a user export""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"), patch( - "bookwyrm.suggested_users.rerank_user_task.delay" - ), patch( - "bookwyrm.lists_stream.remove_list_task.delay" - ), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch( - "bookwyrm.activitystreams.add_book_statuses_task" + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + patch("bookwyrm.suggested_users.rerank_user_task.delay"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_book_statuses_task"), ): self.local_user = models.User.objects.create_user( diff --git a/bookwyrm/tests/models/test_bookwyrm_import_job.py b/bookwyrm/tests/models/test_bookwyrm_import_job.py index adc04706c..50c136f21 100644 --- a/bookwyrm/tests/models/test_bookwyrm_import_job.py +++ b/bookwyrm/tests/models/test_bookwyrm_import_job.py @@ -18,10 +18,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods def setUp(self): """setting stuff up""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"), patch( - "bookwyrm.suggested_users.rerank_user_task.delay" + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + patch("bookwyrm.suggested_users.rerank_user_task.delay"), ): self.local_user = models.User.objects.create_user( @@ -78,9 +79,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods def test_update_user_profile(self): """Test update the user's profile from import data""" - with patch("bookwyrm.suggested_users.remove_user_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.suggested_users.rerank_user_task.delay"): + with ( + patch("bookwyrm.suggested_users.remove_user_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.suggested_users.rerank_user_task.delay"), + ): with open(self.archive_file, "rb") as fileobj: with BookwyrmTarFile.open(mode="r:gz", fileobj=fileobj) as tarfile: @@ -103,9 +106,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods def test_update_user_settings(self): """Test updating the user's settings from import data""" - with patch("bookwyrm.suggested_users.remove_user_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.suggested_users.rerank_user_task.delay"): + with ( + patch("bookwyrm.suggested_users.remove_user_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.suggested_users.rerank_user_task.delay"), + ): models.bookwyrm_import_job.update_user_settings( self.local_user, self.json_data @@ -145,8 +150,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods def test_upsert_saved_lists_existing(self): """Test upserting an existing saved list""" - with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): book_list = models.List.objects.create( name="My cool list", @@ -172,8 +178,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods def test_upsert_saved_lists_not_existing(self): """Test upserting a new saved list""" - with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): book_list = models.List.objects.create( name="My cool list", @@ -199,9 +206,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods self.assertFalse(before_follow) - with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), patch( - "bookwyrm.lists_stream.add_user_lists_task.delay" - ), patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): + with ( + patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), + patch("bookwyrm.lists_stream.add_user_lists_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + ): models.bookwyrm_import_job.upsert_follows( self.local_user, self.json_data.get("follows") ) @@ -222,10 +231,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods ).exists() self.assertFalse(blocked_before) - with patch("bookwyrm.suggested_users.remove_suggestion_task.delay"), patch( - "bookwyrm.activitystreams.remove_user_statuses_task.delay" - ), patch("bookwyrm.lists_stream.remove_user_lists_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.suggested_users.remove_suggestion_task.delay"), + patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"), + patch("bookwyrm.lists_stream.remove_user_lists_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): models.bookwyrm_import_job.upsert_user_blocks( self.local_user, self.json_data.get("blocks") @@ -312,9 +322,10 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods self.assertEqual(models.Review.objects.filter(user=self.local_user).count(), 0) reviews = self.json_data["books"][0]["reviews"] - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True), + ): bookwyrm_import_job.upsert_statuses( self.local_user, models.Review, reviews, self.book.remote_id @@ -349,9 +360,10 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods self.assertEqual(models.Comment.objects.filter(user=self.local_user).count(), 0) comments = self.json_data["books"][1]["comments"] - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True), + ): bookwyrm_import_job.upsert_statuses( self.local_user, models.Comment, comments, self.book.remote_id @@ -378,9 +390,10 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods models.Quotation.objects.filter(user=self.local_user).count(), 0 ) quotes = self.json_data["books"][1]["quotations"] - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True), + ): bookwyrm_import_job.upsert_statuses( self.local_user, models.Quotation, quotes, self.book.remote_id @@ -411,9 +424,10 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods models.Quotation.objects.filter(user=self.local_user).count(), 0 ) quotes = self.json_data["books"][1]["quotations"] - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=False): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=False), + ): bookwyrm_import_job.upsert_statuses( self.local_user, models.Quotation, quotes, self.book.remote_id @@ -432,8 +446,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods title="Another Book", remote_id="https://example.com/book/9876" ) - with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): book_list = models.List.objects.create( name="my list of books", user=self.local_user @@ -452,8 +467,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods 1, ) - with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): bookwyrm_import_job.upsert_lists( self.local_user, @@ -479,8 +495,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods self.assertEqual(models.List.objects.filter(user=self.local_user).count(), 0) self.assertFalse(models.ListItem.objects.filter(book=self.book.id).exists()) - with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.lists_stream.remove_list_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): bookwyrm_import_job.upsert_lists( self.local_user, @@ -503,16 +520,18 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods shelf = models.Shelf.objects.get(name="Read", user=self.local_user) - with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): models.ShelfBook.objects.create( book=self.book, shelf=shelf, user=self.local_user ) book_data = self.json_data["books"][0] - with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): bookwyrm_import_job.upsert_shelves(self.book, self.local_user, book_data) @@ -530,8 +549,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods book_data = self.json_data["books"][0] - with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + with ( + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), ): bookwyrm_import_job.upsert_shelves(self.book, self.local_user, book_data) diff --git a/bookwyrm/tests/models/test_group.py b/bookwyrm/tests/models/test_group.py index 6f5388b19..3ea424333 100644 --- a/bookwyrm/tests/models/test_group.py +++ b/bookwyrm/tests/models/test_group.py @@ -13,9 +13,11 @@ class Group(TestCase): def setUpTestData(self): # pylint: disable=bad-classmethod-argument """Set up for tests""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.owner_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) @@ -81,9 +83,10 @@ class Group(TestCase): """follower-only group booklists should not be excluded from group booklist listing for group members who do not follower list owner""" - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): followers_list = models.List.objects.create( name="Followers List", curation="group", @@ -104,9 +107,10 @@ class Group(TestCase): """private group booklists should not be excluded from group booklist listing for group members""" - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): private_list = models.List.objects.create( name="Private List", privacy="direct", diff --git a/bookwyrm/tests/models/test_import_model.py b/bookwyrm/tests/models/test_import_model.py index 7ca36d223..e5be01464 100644 --- a/bookwyrm/tests/models/test_import_model.py +++ b/bookwyrm/tests/models/test_import_model.py @@ -19,9 +19,11 @@ class ImportJob(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """data is from a goodreads export of The Raven Tower""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True ) diff --git a/bookwyrm/tests/models/test_list.py b/bookwyrm/tests/models/test_list.py index 83d7ed6a5..b1b756cab 100644 --- a/bookwyrm/tests/models/test_list.py +++ b/bookwyrm/tests/models/test_list.py @@ -14,9 +14,11 @@ class List(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """look, a list""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_notification.py b/bookwyrm/tests/models/test_notification.py index 93422640b..a9ed8b661 100644 --- a/bookwyrm/tests/models/test_notification.py +++ b/bookwyrm/tests/models/test_notification.py @@ -10,9 +10,11 @@ class Notification(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """useful things for creating a notification""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) @@ -201,9 +203,11 @@ class NotifyInviteRequest(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """ensure there is one admin""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -264,9 +268,11 @@ class NotifyInviteRequest(TestCase): def test_notify_multiple_admins(self): """all admins are notified""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "admin@local.com", "admin@example.com", diff --git a/bookwyrm/tests/models/test_readthrough_model.py b/bookwyrm/tests/models/test_readthrough_model.py index d34a06aaf..0da87f67b 100644 --- a/bookwyrm/tests/models/test_readthrough_model.py +++ b/bookwyrm/tests/models/test_readthrough_model.py @@ -14,9 +14,11 @@ class ReadThrough(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """look, a shelf""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_relationship_models.py b/bookwyrm/tests/models/test_relationship_models.py index 8f849bc3b..dbb0ac8bb 100644 --- a/bookwyrm/tests/models/test_relationship_models.py +++ b/bookwyrm/tests/models/test_relationship_models.py @@ -27,9 +27,11 @@ class Relationship(TestCase): inbox="https://example.com/users/rat/inbox", outbox="https://example.com/users/rat/outbox", ) - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_shelf_model.py b/bookwyrm/tests/models/test_shelf_model.py index 88b1fad06..2d45dadbc 100644 --- a/bookwyrm/tests/models/test_shelf_model.py +++ b/bookwyrm/tests/models/test_shelf_model.py @@ -18,9 +18,11 @@ class Shelf(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """look, a shelf""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_site.py b/bookwyrm/tests/models/test_site.py index f4accc04b..8cf15ad6f 100644 --- a/bookwyrm/tests/models/test_site.py +++ b/bookwyrm/tests/models/test_site.py @@ -15,9 +15,11 @@ class SiteModels(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/models/test_status_model.py b/bookwyrm/tests/models/test_status_model.py index 9899f6bf3..32ccc2c57 100644 --- a/bookwyrm/tests/models/test_status_model.py +++ b/bookwyrm/tests/models/test_status_model.py @@ -27,9 +27,11 @@ class Status(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """useful things for creating a status""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/models/test_user_model.py b/bookwyrm/tests/models/test_user_model.py index 47a662e49..a47896269 100644 --- a/bookwyrm/tests/models/test_user_model.py +++ b/bookwyrm/tests/models/test_user_model.py @@ -20,9 +20,11 @@ class User(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( f"mouse@{DOMAIN}", "mouse@mouse.mouse", @@ -122,9 +124,11 @@ class User(TestCase): site.default_user_auth_group = Group.objects.get(name="editor") site.save() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): user = models.User.objects.create_user( f"test2{DOMAIN}", "test2@bookwyrm.test", @@ -135,9 +139,11 @@ class User(TestCase): site.default_user_auth_group = None site.save() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): user = models.User.objects.create_user( f"test1{DOMAIN}", "test1@bookwyrm.test", @@ -228,11 +234,14 @@ class User(TestCase): self.assertEqual(self.user.name, "hi") self.assertEqual(self.user.summary, "a summary") self.assertEqual(self.user.email, "mouse@mouse.mouse") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ) as broadcast_mock, patch( - "bookwyrm.models.user.User.erase_user_statuses" - ) as erase_statuses_mock: + with ( + patch( + "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + ) as broadcast_mock, + patch( + "bookwyrm.models.user.User.erase_user_statuses" + ) as erase_statuses_mock, + ): self.user.delete() self.assertEqual(erase_statuses_mock.call_count, 1) diff --git a/bookwyrm/tests/templatetags/test_book_display_tags.py b/bookwyrm/tests/templatetags/test_book_display_tags.py index dcff01a80..77d6fee54 100644 --- a/bookwyrm/tests/templatetags/test_book_display_tags.py +++ b/bookwyrm/tests/templatetags/test_book_display_tags.py @@ -16,9 +16,11 @@ class BookDisplayTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_feed_page_tags.py b/bookwyrm/tests/templatetags/test_feed_page_tags.py index d0a895f36..891bfc32c 100644 --- a/bookwyrm/tests/templatetags/test_feed_page_tags.py +++ b/bookwyrm/tests/templatetags/test_feed_page_tags.py @@ -15,9 +15,11 @@ class FeedPageTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_interaction.py b/bookwyrm/tests/templatetags/test_interaction.py index a9d1267c0..bd66575ff 100644 --- a/bookwyrm/tests/templatetags/test_interaction.py +++ b/bookwyrm/tests/templatetags/test_interaction.py @@ -15,9 +15,11 @@ class InteractionTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_notification_page_tags.py b/bookwyrm/tests/templatetags/test_notification_page_tags.py index 94f839ec5..df2805828 100644 --- a/bookwyrm/tests/templatetags/test_notification_page_tags.py +++ b/bookwyrm/tests/templatetags/test_notification_page_tags.py @@ -15,9 +15,11 @@ class NotificationPageTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_rating_tags.py b/bookwyrm/tests/templatetags/test_rating_tags.py index 5225d57a6..f50236262 100644 --- a/bookwyrm/tests/templatetags/test_rating_tags.py +++ b/bookwyrm/tests/templatetags/test_rating_tags.py @@ -15,9 +15,11 @@ class RatingTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_shelf_tags.py b/bookwyrm/tests/templatetags/test_shelf_tags.py index 7c456c815..47e86d9ef 100644 --- a/bookwyrm/tests/templatetags/test_shelf_tags.py +++ b/bookwyrm/tests/templatetags/test_shelf_tags.py @@ -18,9 +18,11 @@ class ShelfTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_status_display.py b/bookwyrm/tests/templatetags/test_status_display.py index a9bab0b68..af125fd06 100644 --- a/bookwyrm/tests/templatetags/test_status_display.py +++ b/bookwyrm/tests/templatetags/test_status_display.py @@ -17,9 +17,11 @@ class StatusDisplayTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/templatetags/test_utilities.py b/bookwyrm/tests/templatetags/test_utilities.py index 1bf98fda8..6fade22a7 100644 --- a/bookwyrm/tests/templatetags/test_utilities.py +++ b/bookwyrm/tests/templatetags/test_utilities.py @@ -17,9 +17,11 @@ class UtilitiesTags(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create some filler objects""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/test_context_processors.py b/bookwyrm/tests/test_context_processors.py index 614db681c..e5290f312 100644 --- a/bookwyrm/tests/test_context_processors.py +++ b/bookwyrm/tests/test_context_processors.py @@ -14,9 +14,11 @@ class ContextProcessor(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/test_emailing.py b/bookwyrm/tests/test_emailing.py index 119941e85..8a5b543d5 100644 --- a/bookwyrm/tests/test_emailing.py +++ b/bookwyrm/tests/test_emailing.py @@ -14,9 +14,11 @@ class Emailing(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/test_preview_images.py b/bookwyrm/tests/test_preview_images.py index d1998bf3c..4f711b38b 100644 --- a/bookwyrm/tests/test_preview_images.py +++ b/bookwyrm/tests/test_preview_images.py @@ -31,9 +31,11 @@ class PreviewImages(TestCase): avatar_file = pathlib.Path(__file__).parent.joinpath( "../static/images/no_cover.jpg" ) - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "possum@local.com", "possum@possum.possum", @@ -47,9 +49,11 @@ class PreviewImages(TestCase): ), ) - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.remote_user = models.User.objects.create_user( "rat", "rat@rat.com", @@ -60,9 +64,11 @@ class PreviewImages(TestCase): outbox="https://example.com/users/rat/outbox", ) - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.remote_user_with_preview = models.User.objects.create_user( "badger@your.domain.here", "badger@badger.com", diff --git a/bookwyrm/tests/test_signing.py b/bookwyrm/tests/test_signing.py index b539f089b..80a35b94d 100644 --- a/bookwyrm/tests/test_signing.py +++ b/bookwyrm/tests/test_signing.py @@ -38,9 +38,11 @@ class Signature(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """create users and test data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.mouse = models.User.objects.create_user( f"mouse@{DOMAIN}", "mouse@example.com", diff --git a/bookwyrm/tests/test_suggested_users.py b/bookwyrm/tests/test_suggested_users.py index 77b82e7ee..0a6dd8abe 100644 --- a/bookwyrm/tests/test_suggested_users.py +++ b/bookwyrm/tests/test_suggested_users.py @@ -22,9 +22,11 @@ class SuggestedUsers(TestCase): def setUp(self): """use a test csv""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" ) diff --git a/bookwyrm/tests/views/admin/test_announcements.py b/bookwyrm/tests/views/admin/test_announcements.py index 30bc94a1f..958d78fc4 100644 --- a/bookwyrm/tests/views/admin/test_announcements.py +++ b/bookwyrm/tests/views/admin/test_announcements.py @@ -14,9 +14,11 @@ class AnnouncementViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_automod.py b/bookwyrm/tests/views/admin/test_automod.py index 1835a24ee..332410eba 100644 --- a/bookwyrm/tests/views/admin/test_automod.py +++ b/bookwyrm/tests/views/admin/test_automod.py @@ -18,9 +18,11 @@ class AutomodViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_celery.py b/bookwyrm/tests/views/admin/test_celery.py index d215a9657..577d312b1 100644 --- a/bookwyrm/tests/views/admin/test_celery.py +++ b/bookwyrm/tests/views/admin/test_celery.py @@ -17,9 +17,11 @@ class CeleryStatusViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_dashboard.py b/bookwyrm/tests/views/admin/test_dashboard.py index 8eeb754a8..a68b046e3 100644 --- a/bookwyrm/tests/views/admin/test_dashboard.py +++ b/bookwyrm/tests/views/admin/test_dashboard.py @@ -17,9 +17,11 @@ class DashboardViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_email_blocks.py b/bookwyrm/tests/views/admin/test_email_blocks.py index 75c0be929..b37166d3c 100644 --- a/bookwyrm/tests/views/admin/test_email_blocks.py +++ b/bookwyrm/tests/views/admin/test_email_blocks.py @@ -17,9 +17,11 @@ class EmailBlocklistViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_email_config.py b/bookwyrm/tests/views/admin/test_email_config.py index 63d85cbef..374c2402e 100644 --- a/bookwyrm/tests/views/admin/test_email_config.py +++ b/bookwyrm/tests/views/admin/test_email_config.py @@ -17,9 +17,11 @@ class EmailConfigViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_federation.py b/bookwyrm/tests/views/admin/test_federation.py index 1a5067299..8244e8335 100644 --- a/bookwyrm/tests/views/admin/test_federation.py +++ b/bookwyrm/tests/views/admin/test_federation.py @@ -20,9 +20,11 @@ class FederationViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_imports.py b/bookwyrm/tests/views/admin/test_imports.py index 5a5599519..acb769546 100644 --- a/bookwyrm/tests/views/admin/test_imports.py +++ b/bookwyrm/tests/views/admin/test_imports.py @@ -17,9 +17,11 @@ class ImportsAdminViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_ip_blocklist.py b/bookwyrm/tests/views/admin/test_ip_blocklist.py index 06c110a06..b34828622 100644 --- a/bookwyrm/tests/views/admin/test_ip_blocklist.py +++ b/bookwyrm/tests/views/admin/test_ip_blocklist.py @@ -17,9 +17,11 @@ class IPBlocklistViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_link_domains.py b/bookwyrm/tests/views/admin/test_link_domains.py index 14eed419b..fabb7511a 100644 --- a/bookwyrm/tests/views/admin/test_link_domains.py +++ b/bookwyrm/tests/views/admin/test_link_domains.py @@ -17,9 +17,11 @@ class LinkDomainViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_reports.py b/bookwyrm/tests/views/admin/test_reports.py index 4334eeed9..7ce665451 100644 --- a/bookwyrm/tests/views/admin/test_reports.py +++ b/bookwyrm/tests/views/admin/test_reports.py @@ -18,9 +18,11 @@ class ReportViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_site.py b/bookwyrm/tests/views/admin/test_site.py index b7c687e09..ec5b07e3a 100644 --- a/bookwyrm/tests/views/admin/test_site.py +++ b/bookwyrm/tests/views/admin/test_site.py @@ -17,9 +17,11 @@ class SiteSettingsViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_themes.py b/bookwyrm/tests/views/admin/test_themes.py index 66384f5fc..b931ea561 100644 --- a/bookwyrm/tests/views/admin/test_themes.py +++ b/bookwyrm/tests/views/admin/test_themes.py @@ -18,9 +18,11 @@ class AdminThemesViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/admin/test_user_admin.py b/bookwyrm/tests/views/admin/test_user_admin.py index 99c630526..5247ff70f 100644 --- a/bookwyrm/tests/views/admin/test_user_admin.py +++ b/bookwyrm/tests/views/admin/test_user_admin.py @@ -18,9 +18,11 @@ class UserAdminViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/books/test_book.py b/bookwyrm/tests/views/books/test_book.py index 4d41eaa5d..68a114fb9 100644 --- a/bookwyrm/tests/views/books/test_book.py +++ b/bookwyrm/tests/views/books/test_book.py @@ -26,9 +26,11 @@ class BookViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/books/test_edit_book.py b/bookwyrm/tests/views/books/test_edit_book.py index 169112bab..0bd962de5 100644 --- a/bookwyrm/tests/views/books/test_edit_book.py +++ b/bookwyrm/tests/views/books/test_edit_book.py @@ -22,9 +22,11 @@ class EditBookViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/books/test_editions.py b/bookwyrm/tests/views/books/test_editions.py index e89fd521b..b829d471b 100644 --- a/bookwyrm/tests/views/books/test_editions.py +++ b/bookwyrm/tests/views/books/test_editions.py @@ -16,9 +16,11 @@ class BookViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/books/test_links.py b/bookwyrm/tests/views/books/test_links.py index 817463656..d1040a591 100644 --- a/bookwyrm/tests/views/books/test_links.py +++ b/bookwyrm/tests/views/books/test_links.py @@ -18,8 +18,9 @@ class LinkViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), ): self.local_user = models.User.objects.create_user( "mouse@local.com", diff --git a/bookwyrm/tests/views/imports/test_import.py b/bookwyrm/tests/views/imports/test_import.py index d0612ee68..c3b2795b1 100644 --- a/bookwyrm/tests/views/imports/test_import.py +++ b/bookwyrm/tests/views/imports/test_import.py @@ -19,9 +19,11 @@ class ImportViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/imports/test_import_review.py b/bookwyrm/tests/views/imports/test_import_review.py index 27bb3f9d1..5da02a56a 100644 --- a/bookwyrm/tests/views/imports/test_import_review.py +++ b/bookwyrm/tests/views/imports/test_import_review.py @@ -14,9 +14,11 @@ class ImportManualReviewViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/imports/test_import_troubleshoot.py b/bookwyrm/tests/views/imports/test_import_troubleshoot.py index 0e12c406a..9ddc99785 100644 --- a/bookwyrm/tests/views/imports/test_import_troubleshoot.py +++ b/bookwyrm/tests/views/imports/test_import_troubleshoot.py @@ -15,9 +15,11 @@ class ImportTroubleshootViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/imports/test_user_import.py b/bookwyrm/tests/views/imports/test_user_import.py index db5837101..4a676a57f 100644 --- a/bookwyrm/tests/views/imports/test_user_import.py +++ b/bookwyrm/tests/views/imports/test_user_import.py @@ -18,9 +18,11 @@ class ImportUserViews(TestCase): def setUp(self): """we need basic test data and mocks""" self.factory = RequestFactory() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/inbox/test_inbox.py b/bookwyrm/tests/views/inbox/test_inbox.py index 1c05806a5..af85e84d4 100644 --- a/bookwyrm/tests/views/inbox/test_inbox.py +++ b/bookwyrm/tests/views/inbox/test_inbox.py @@ -31,9 +31,11 @@ class Inbox(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_add.py b/bookwyrm/tests/views/inbox/test_inbox_add.py index 5fbeaa33a..2bd5faf6a 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_add.py +++ b/bookwyrm/tests/views/inbox/test_inbox_add.py @@ -14,9 +14,11 @@ class InboxAdd(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_announce.py b/bookwyrm/tests/views/inbox/test_inbox_announce.py index e6fdf9375..53555f213 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_announce.py +++ b/bookwyrm/tests/views/inbox/test_inbox_announce.py @@ -14,9 +14,11 @@ class InboxActivities(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_block.py b/bookwyrm/tests/views/inbox/test_inbox_block.py index 9fef621ea..9cdf7eba3 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_block.py +++ b/bookwyrm/tests/views/inbox/test_inbox_block.py @@ -13,9 +13,11 @@ class InboxBlock(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", @@ -56,9 +58,12 @@ class InboxBlock(TestCase): "object": "https://example.com/user/mouse", } - with patch( - "bookwyrm.activitystreams.remove_user_statuses_task.delay" - ) as redis_mock, patch("bookwyrm.lists_stream.remove_user_lists_task.delay"): + with ( + patch( + "bookwyrm.activitystreams.remove_user_statuses_task.delay" + ) as redis_mock, + patch("bookwyrm.lists_stream.remove_user_lists_task.delay"), + ): views.inbox.activity_task(activity) self.assertTrue(redis_mock.called) views.inbox.activity_task(activity) diff --git a/bookwyrm/tests/views/inbox/test_inbox_create.py b/bookwyrm/tests/views/inbox/test_inbox_create.py index c2045b092..7f5be5b65 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_create.py +++ b/bookwyrm/tests/views/inbox/test_inbox_create.py @@ -15,9 +15,11 @@ class TransactionInboxCreate(TransactionTestCase): def setUp(self): """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", @@ -74,9 +76,11 @@ class InboxCreate(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_delete.py b/bookwyrm/tests/views/inbox/test_inbox_delete.py index 8023308be..9c2b589e2 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_delete.py +++ b/bookwyrm/tests/views/inbox/test_inbox_delete.py @@ -14,9 +14,11 @@ class InboxActivities(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_follow.py b/bookwyrm/tests/views/inbox/test_inbox_follow.py index 180a57176..8ccffe1db 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_follow.py +++ b/bookwyrm/tests/views/inbox/test_inbox_follow.py @@ -14,9 +14,11 @@ class InboxRelationships(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_like.py b/bookwyrm/tests/views/inbox/test_inbox_like.py index 34c8c830b..4a397dcf8 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_like.py +++ b/bookwyrm/tests/views/inbox/test_inbox_like.py @@ -13,9 +13,11 @@ class InboxActivities(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/inbox/test_inbox_remove.py b/bookwyrm/tests/views/inbox/test_inbox_remove.py index d80a4fdd7..f0be2b17a 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_remove.py +++ b/bookwyrm/tests/views/inbox/test_inbox_remove.py @@ -13,9 +13,11 @@ class InboxRemove(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", @@ -76,9 +78,10 @@ class InboxRemove(TestCase): def test_handle_remove_book_from_list(self): """listing a book""" - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): booklist = models.List.objects.create( name="test list", user=self.local_user, diff --git a/bookwyrm/tests/views/inbox/test_inbox_update.py b/bookwyrm/tests/views/inbox/test_inbox_update.py index b9f924bad..fb2c85a88 100644 --- a/bookwyrm/tests/views/inbox/test_inbox_update.py +++ b/bookwyrm/tests/views/inbox/test_inbox_update.py @@ -15,9 +15,11 @@ class InboxUpdate(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """basic user and book data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@example.com", "mouse@mouse.com", @@ -53,9 +55,10 @@ class InboxUpdate(TestCase): def test_update_list(self): """a new list""" - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): book_list = models.List.objects.create( name="hi", remote_id="https://example.com/list/22", user=self.local_user ) diff --git a/bookwyrm/tests/views/landing/test_invite.py b/bookwyrm/tests/views/landing/test_invite.py index f7ec73cf4..5a76f578b 100644 --- a/bookwyrm/tests/views/landing/test_invite.py +++ b/bookwyrm/tests/views/landing/test_invite.py @@ -17,9 +17,11 @@ class InviteViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/landing/test_landing.py b/bookwyrm/tests/views/landing/test_landing.py index b67857da8..c0581d893 100644 --- a/bookwyrm/tests/views/landing/test_landing.py +++ b/bookwyrm/tests/views/landing/test_landing.py @@ -17,9 +17,11 @@ class LandingViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/landing/test_login.py b/bookwyrm/tests/views/landing/test_login.py index 19ad1d2a0..283890e3e 100644 --- a/bookwyrm/tests/views/landing/test_login.py +++ b/bookwyrm/tests/views/landing/test_login.py @@ -20,9 +20,11 @@ class LoginViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@your.domain.here", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/landing/test_password.py b/bookwyrm/tests/views/landing/test_password.py index ceceeb3e4..8f322b3cb 100644 --- a/bookwyrm/tests/views/landing/test_password.py +++ b/bookwyrm/tests/views/landing/test_password.py @@ -19,9 +19,11 @@ class PasswordViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/landing/test_register.py b/bookwyrm/tests/views/landing/test_register.py index 381a35a32..4b3d46673 100644 --- a/bookwyrm/tests/views/landing/test_register.py +++ b/bookwyrm/tests/views/landing/test_register.py @@ -23,9 +23,11 @@ class RegisterViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@your.domain.here", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/lists/test_curate.py b/bookwyrm/tests/views/lists/test_curate.py index 7fa48f915..59d73cefd 100644 --- a/bookwyrm/tests/views/lists/test_curate.py +++ b/bookwyrm/tests/views/lists/test_curate.py @@ -18,9 +18,11 @@ class ListViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -36,9 +38,10 @@ class ListViews(TestCase): parent_work=work, ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): self.list = models.List.objects.create( name="Test List", user=self.local_user ) diff --git a/bookwyrm/tests/views/lists/test_embed.py b/bookwyrm/tests/views/lists/test_embed.py index 40c51f5df..9c1d3846d 100644 --- a/bookwyrm/tests/views/lists/test_embed.py +++ b/bookwyrm/tests/views/lists/test_embed.py @@ -18,9 +18,11 @@ class ListViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -36,9 +38,10 @@ class ListViews(TestCase): parent_work=work, ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): self.list = models.List.objects.create( name="Test List", user=self.local_user ) diff --git a/bookwyrm/tests/views/lists/test_list.py b/bookwyrm/tests/views/lists/test_list.py index b1e7e2acc..dc144c134 100644 --- a/bookwyrm/tests/views/lists/test_list.py +++ b/bookwyrm/tests/views/lists/test_list.py @@ -21,9 +21,11 @@ class ListViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -65,9 +67,10 @@ class ListViews(TestCase): parent_work=work_four, ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): self.list = models.List.objects.create( name="Test List", user=self.local_user ) @@ -248,9 +251,12 @@ class ListViews(TestCase): ) request.user = self.local_user - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch( + "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + ) as mock, + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): result = view(request, self.list.id) self.assertEqual(mock.call_count, 1) @@ -286,9 +292,12 @@ class ListViews(TestCase): ) request = self.factory.post("") request.user = self.local_user - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay") as redis_mock: + with ( + patch( + "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + ) as mock, + patch("bookwyrm.lists_stream.remove_list_task.delay") as redis_mock, + ): views.delete_list(request, self.list.id) self.assertTrue(redis_mock.called) activity = json.loads(mock.call_args[1]["args"][1]) diff --git a/bookwyrm/tests/views/lists/test_list_item.py b/bookwyrm/tests/views/lists/test_list_item.py index ebdbdbc2e..e265d7ef5 100644 --- a/bookwyrm/tests/views/lists/test_list_item.py +++ b/bookwyrm/tests/views/lists/test_list_item.py @@ -15,9 +15,11 @@ class ListItemViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -32,9 +34,10 @@ class ListItemViews(TestCase): remote_id="https://example.com/book/1", parent_work=work, ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): self.list = models.List.objects.create( name="Test List", user=self.local_user ) diff --git a/bookwyrm/tests/views/lists/test_lists.py b/bookwyrm/tests/views/lists/test_lists.py index 0d2213ee7..88ea71360 100644 --- a/bookwyrm/tests/views/lists/test_lists.py +++ b/bookwyrm/tests/views/lists/test_lists.py @@ -18,9 +18,11 @@ class ListViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -45,10 +47,10 @@ class ListViews(TestCase): def test_lists_page(self, _): """there are so many views, this just makes sure it LOADS""" view = views.Lists.as_view() - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.add_list_task.delay"), patch( - "bookwyrm.lists_stream.remove_list_task.delay" + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.add_list_task.delay"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), ): models.List.objects.create(name="Public list", user=self.local_user) models.List.objects.create( @@ -72,9 +74,10 @@ class ListViews(TestCase): def test_saved_lists_page(self): """there are so many views, this just makes sure it LOADS""" view = views.SavedLists.as_view() - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): booklist = models.List.objects.create( name="Public list", user=self.local_user ) @@ -94,9 +97,10 @@ class ListViews(TestCase): def test_saved_lists_page_empty(self): """there are so many views, this just makes sure it LOADS""" view = views.SavedLists.as_view() - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): models.List.objects.create(name="Public list", user=self.local_user) models.List.objects.create( name="Private list", privacy="direct", user=self.local_user @@ -122,9 +126,10 @@ class ListViews(TestCase): def test_user_lists_page(self): """there are so many views, this just makes sure it LOADS""" view = views.UserLists.as_view() - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): models.List.objects.create(name="Public list", user=self.local_user) models.List.objects.create( name="Private list", privacy="direct", user=self.local_user @@ -160,9 +165,12 @@ class ListViews(TestCase): }, ) request.user = self.local_user - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch( + "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" + ) as mock, + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): result = view(request) self.assertEqual(mock.call_count, 1) diff --git a/bookwyrm/tests/views/preferences/test_block.py b/bookwyrm/tests/views/preferences/test_block.py index 86ef95e7e..bc39d2f62 100644 --- a/bookwyrm/tests/views/preferences/test_block.py +++ b/bookwyrm/tests/views/preferences/test_block.py @@ -16,9 +16,11 @@ class BlockViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -65,8 +67,9 @@ class BlockViews(TestCase): request = self.factory.post("") request.user = self.local_user - with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"), patch( - "bookwyrm.lists_stream.remove_user_lists_task.delay" + with ( + patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"), + patch("bookwyrm.lists_stream.remove_user_lists_task.delay"), ): view(request, self.remote_user.id) block = models.UserBlocks.objects.get() @@ -82,8 +85,9 @@ class BlockViews(TestCase): request = self.factory.post("") request.user = self.local_user - with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), patch( - "bookwyrm.lists_stream.add_user_lists_task.delay" + with ( + patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), + patch("bookwyrm.lists_stream.add_user_lists_task.delay"), ): views.unblock(request, self.remote_user.id) diff --git a/bookwyrm/tests/views/preferences/test_change_password.py b/bookwyrm/tests/views/preferences/test_change_password.py index 49eac998c..1717204bd 100644 --- a/bookwyrm/tests/views/preferences/test_change_password.py +++ b/bookwyrm/tests/views/preferences/test_change_password.py @@ -15,9 +15,11 @@ class ChangePasswordViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/preferences/test_delete_user.py b/bookwyrm/tests/views/preferences/test_delete_user.py index d97ef0d38..94d8c4a69 100644 --- a/bookwyrm/tests/views/preferences/test_delete_user.py +++ b/bookwyrm/tests/views/preferences/test_delete_user.py @@ -19,9 +19,11 @@ class DeleteUserViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@your.domain.here", "mouse@mouse.mouse", @@ -40,9 +42,10 @@ class DeleteUserViews(TestCase): self.book = models.Edition.objects.create( title="test", parent_work=models.Work.objects.create(title="test work") ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), + ): models.ShelfBook.objects.create( book=self.book, user=self.local_user, diff --git a/bookwyrm/tests/views/preferences/test_edit_user.py b/bookwyrm/tests/views/preferences/test_edit_user.py index 1ed4e3240..4b83f3b80 100644 --- a/bookwyrm/tests/views/preferences/test_edit_user.py +++ b/bookwyrm/tests/views/preferences/test_edit_user.py @@ -21,9 +21,11 @@ class EditUserViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -38,9 +40,10 @@ class EditUserViews(TestCase): self.book = models.Edition.objects.create( title="test", parent_work=models.Work.objects.create(title="test work") ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), + ): models.ShelfBook.objects.create( book=self.book, user=self.local_user, diff --git a/bookwyrm/tests/views/preferences/test_export.py b/bookwyrm/tests/views/preferences/test_export.py index 3f758b2f7..128b8fc8b 100644 --- a/bookwyrm/tests/views/preferences/test_export.py +++ b/bookwyrm/tests/views/preferences/test_export.py @@ -22,8 +22,9 @@ class ExportViews(TestCase): self, ): # pylint: disable=bad-classmethod-argument, disable=invalid-name """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), ): self.local_user = models.User.objects.create_user( "mouse@local.com", diff --git a/bookwyrm/tests/views/preferences/test_export_user.py b/bookwyrm/tests/views/preferences/test_export_user.py index 654ed2a05..57a7c2ca5 100644 --- a/bookwyrm/tests/views/preferences/test_export_user.py +++ b/bookwyrm/tests/views/preferences/test_export_user.py @@ -15,8 +15,9 @@ class ExportUserViews(TestCase): def setUp(self): self.factory = RequestFactory() models.SiteSettings.objects.create() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), ): self.local_user = models.User.objects.create_user( "hugh@example.com", diff --git a/bookwyrm/tests/views/preferences/test_two_factor_auth.py b/bookwyrm/tests/views/preferences/test_two_factor_auth.py index dbd9c1f5b..8eb5e92c7 100644 --- a/bookwyrm/tests/views/preferences/test_two_factor_auth.py +++ b/bookwyrm/tests/views/preferences/test_two_factor_auth.py @@ -20,9 +20,11 @@ class TwoFactorViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@your.domain.here", "mouse@mouse.com", @@ -130,8 +132,9 @@ class TwoFactorViews(TestCase): request.session["2fa_user"] = self.local_user.username request.session.save() - with patch("bookwyrm.views.preferences.two_factor_auth.LoginWith2FA"), patch( - "bookwyrm.views.preferences.two_factor_auth.login" + with ( + patch("bookwyrm.views.preferences.two_factor_auth.LoginWith2FA"), + patch("bookwyrm.views.preferences.two_factor_auth.login"), ): result = view(request) self.assertEqual(result.url, "/") diff --git a/bookwyrm/tests/views/shelf/test_shelf.py b/bookwyrm/tests/views/shelf/test_shelf.py index b96d0a9ed..57631974f 100644 --- a/bookwyrm/tests/views/shelf/test_shelf.py +++ b/bookwyrm/tests/views/shelf/test_shelf.py @@ -23,9 +23,11 @@ class ShelfViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/shelf/test_shelf_actions.py b/bookwyrm/tests/views/shelf/test_shelf_actions.py index eea17b62d..ee5854d18 100644 --- a/bookwyrm/tests/views/shelf/test_shelf_actions.py +++ b/bookwyrm/tests/views/shelf/test_shelf_actions.py @@ -21,9 +21,11 @@ class ShelfActionViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_annual_summary.py b/bookwyrm/tests/views/test_annual_summary.py index d51060a72..2fd7dc4eb 100644 --- a/bookwyrm/tests/views/test_annual_summary.py +++ b/bookwyrm/tests/views/test_annual_summary.py @@ -24,9 +24,11 @@ class AnnualSummary(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_author.py b/bookwyrm/tests/views/test_author.py index 669149af2..bee057d0c 100644 --- a/bookwyrm/tests/views/test_author.py +++ b/bookwyrm/tests/views/test_author.py @@ -19,9 +19,11 @@ class AuthorViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_directory.py b/bookwyrm/tests/views/test_directory.py index 7e9e97522..e2bef539e 100644 --- a/bookwyrm/tests/views/test_directory.py +++ b/bookwyrm/tests/views/test_directory.py @@ -16,9 +16,11 @@ class DirectoryViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_discover.py b/bookwyrm/tests/views/test_discover.py index 9aa139074..937039592 100644 --- a/bookwyrm/tests/views/test_discover.py +++ b/bookwyrm/tests/views/test_discover.py @@ -14,9 +14,11 @@ class DiscoverViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/test_feed.py b/bookwyrm/tests/views/test_feed.py index 33dbd4ea5..fb2609575 100644 --- a/bookwyrm/tests/views/test_feed.py +++ b/bookwyrm/tests/views/test_feed.py @@ -27,9 +27,11 @@ class FeedViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/test_follow.py b/bookwyrm/tests/views/test_follow.py index e70ace769..61a0a82ce 100644 --- a/bookwyrm/tests/views/test_follow.py +++ b/bookwyrm/tests/views/test_follow.py @@ -21,9 +21,11 @@ class FollowViews(TestCase): def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" models.SiteSettings.objects.create() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -78,9 +80,11 @@ class FollowViews(TestCase): def test_handle_follow_local_manually_approves(self, *_): """send a follow request""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): rat = models.User.objects.create_user( "rat@local.com", "rat@rat.com", @@ -104,9 +108,11 @@ class FollowViews(TestCase): def test_handle_follow_local(self, *_): """send a follow request""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): rat = models.User.objects.create_user( "rat@local.com", "rat@rat.com", diff --git a/bookwyrm/tests/views/test_get_started.py b/bookwyrm/tests/views/test_get_started.py index 84a49cafc..5d6aa8782 100644 --- a/bookwyrm/tests/views/test_get_started.py +++ b/bookwyrm/tests/views/test_get_started.py @@ -15,9 +15,11 @@ class GetStartedViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/test_goal.py b/bookwyrm/tests/views/test_goal.py index 3d87d8538..49227457b 100644 --- a/bookwyrm/tests/views/test_goal.py +++ b/bookwyrm/tests/views/test_goal.py @@ -18,9 +18,11 @@ class GoalViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_group.py b/bookwyrm/tests/views/test_group.py index 4d678c31a..ca9284686 100644 --- a/bookwyrm/tests/views/test_group.py +++ b/bookwyrm/tests/views/test_group.py @@ -19,9 +19,11 @@ class GroupViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", diff --git a/bookwyrm/tests/views/test_hashtag.py b/bookwyrm/tests/views/test_hashtag.py index 1c8b31dce..5979238d8 100644 --- a/bookwyrm/tests/views/test_hashtag.py +++ b/bookwyrm/tests/views/test_hashtag.py @@ -16,9 +16,11 @@ class HashtagView(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -53,9 +55,10 @@ class HashtagView(TestCase): ) self.hashtag_bookclub = models.Hashtag.objects.create(name="#BookClub") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_status_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_status_task.delay"), + ): self.statuses_bookclub = [ models.Comment.objects.create( book=self.book, user=self.local_user, content="#BookClub" @@ -91,9 +94,10 @@ class HashtagView(TestCase): request = self.factory.get("") hashtag = models.Hashtag.objects.create(name="#test") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_status_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_status_task.delay"), + ): status = models.Comment.objects.create( user=self.local_user, book=self.book, content="#test", privacy="direct" ) @@ -115,9 +119,10 @@ class HashtagView(TestCase): request = self.factory.get("") hashtag = models.Hashtag.objects.create(name="#test") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_status_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_status_task.delay"), + ): status = models.Comment.objects.create( user=self.local_user, book=self.book, @@ -143,9 +148,10 @@ class HashtagView(TestCase): request = self.factory.get("") hashtag = models.Hashtag.objects.create(name="#test") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_status_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_status_task.delay"), + ): status = models.Comment.objects.create( user=self.local_user, book=self.book, diff --git a/bookwyrm/tests/views/test_helpers.py b/bookwyrm/tests/views/test_helpers.py index 9472cf762..2f2481931 100644 --- a/bookwyrm/tests/views/test_helpers.py +++ b/bookwyrm/tests/views/test_helpers.py @@ -21,9 +21,11 @@ class ViewsHelpers(TestCase): # pylint: disable=too-many-public-methods @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): with patch("bookwyrm.suggested_users.rerank_user_task.delay"): self.local_user = models.User.objects.create_user( "mouse@local.com", diff --git a/bookwyrm/tests/views/test_interaction.py b/bookwyrm/tests/views/test_interaction.py index 1565b96a8..95d7b5791 100644 --- a/bookwyrm/tests/views/test_interaction.py +++ b/bookwyrm/tests/views/test_interaction.py @@ -15,9 +15,11 @@ class InteractionViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_isbn.py b/bookwyrm/tests/views/test_isbn.py index ca451bef8..bb66c8f3e 100644 --- a/bookwyrm/tests/views/test_isbn.py +++ b/bookwyrm/tests/views/test_isbn.py @@ -17,9 +17,11 @@ class IsbnViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_notifications.py b/bookwyrm/tests/views/test_notifications.py index 8d239d77a..c44940742 100644 --- a/bookwyrm/tests/views/test_notifications.py +++ b/bookwyrm/tests/views/test_notifications.py @@ -15,9 +15,11 @@ class NotificationViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -148,9 +150,10 @@ class NotificationViews(TestCase): def test_notifications_page_list(self): """Adding books to lists""" book = models.Edition.objects.create(title="shape") - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): book_list = models.List.objects.create(user=self.local_user, name="hi") item = models.ListItem.objects.create( book=book, user=self.another_user, book_list=book_list, order=1 diff --git a/bookwyrm/tests/views/test_outbox.py b/bookwyrm/tests/views/test_outbox.py index 78c4d0edc..ca289db3f 100644 --- a/bookwyrm/tests/views/test_outbox.py +++ b/bookwyrm/tests/views/test_outbox.py @@ -18,9 +18,11 @@ class OutboxView(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we'll need some data""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_reading.py b/bookwyrm/tests/views/test_reading.py index fab1c1fc9..39c611d6c 100644 --- a/bookwyrm/tests/views/test_reading.py +++ b/bookwyrm/tests/views/test_reading.py @@ -18,9 +18,11 @@ class ReadingViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_readthrough.py b/bookwyrm/tests/views/test_readthrough.py index 4f5b1e478..113b3161d 100644 --- a/bookwyrm/tests/views/test_readthrough.py +++ b/bookwyrm/tests/views/test_readthrough.py @@ -24,9 +24,11 @@ class ReadThrough(TestCase): title="Example Edition", parent_work=self.work ) - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.user = models.User.objects.create_user( "cinco", "cinco@example.com", "seissiete", local=True, localname="cinco" ) diff --git a/bookwyrm/tests/views/test_report.py b/bookwyrm/tests/views/test_report.py index 3e4c64f68..65670dcbf 100644 --- a/bookwyrm/tests/views/test_report.py +++ b/bookwyrm/tests/views/test_report.py @@ -14,9 +14,11 @@ class ReportViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -31,9 +33,10 @@ class ReportViews(TestCase): local=True, localname="rat", ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.activitystreams.add_status_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.activitystreams.add_status_task.delay"), + ): self.status = models.Status.objects.create( user=self.local_user, content="Test status", diff --git a/bookwyrm/tests/views/test_rss_feed.py b/bookwyrm/tests/views/test_rss_feed.py index a63bdea94..af5ad5301 100644 --- a/bookwyrm/tests/views/test_rss_feed.py +++ b/bookwyrm/tests/views/test_rss_feed.py @@ -14,9 +14,11 @@ class RssFeedView(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "rss_user", "rss@test.rss", "password", local=True ) diff --git a/bookwyrm/tests/views/test_search.py b/bookwyrm/tests/views/test_search.py index 425b96cd3..5e06e6f81 100644 --- a/bookwyrm/tests/views/test_search.py +++ b/bookwyrm/tests/views/test_search.py @@ -20,9 +20,11 @@ class Views(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -164,9 +166,10 @@ class Views(TestCase): def test_search_lists(self): """searches remote connectors""" - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.lists_stream.remove_list_task.delay"): + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.lists_stream.remove_list_task.delay"), + ): booklist = models.List.objects.create( user=self.local_user, name="test list" ) diff --git a/bookwyrm/tests/views/test_status.py b/bookwyrm/tests/views/test_status.py index 7b0c39338..f5fe515f1 100644 --- a/bookwyrm/tests/views/test_status.py +++ b/bookwyrm/tests/views/test_status.py @@ -19,9 +19,11 @@ class StatusTransactions(TransactionTestCase): def setUp(self): """we need basic test data and mocks""" self.factory = RequestFactory() - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", @@ -77,9 +79,11 @@ class StatusViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.com", diff --git a/bookwyrm/tests/views/test_updates.py b/bookwyrm/tests/views/test_updates.py index 37cb2e6c6..129aa8d71 100644 --- a/bookwyrm/tests/views/test_updates.py +++ b/bookwyrm/tests/views/test_updates.py @@ -15,9 +15,11 @@ class UpdateViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -54,11 +56,14 @@ class UpdateViews(TestCase): request = self.factory.get("") request.user = self.local_user - with patch( - "bookwyrm.activitystreams.ActivityStream.get_unread_count" - ) as mock_count, patch( - "bookwyrm.activitystreams.ActivityStream.get_unread_count_by_status_type" - ) as mock_count_by_status: + with ( + patch( + "bookwyrm.activitystreams.ActivityStream.get_unread_count" + ) as mock_count, + patch( + "bookwyrm.activitystreams.ActivityStream.get_unread_count_by_status_type" + ) as mock_count_by_status, + ): mock_count.return_value = 3 mock_count_by_status.return_value = {"review": 5} result = views.get_unread_status_string(request, "home") @@ -73,11 +78,14 @@ class UpdateViews(TestCase): request = self.factory.get("") request.user = self.local_user - with patch( - "bookwyrm.activitystreams.ActivityStream.get_unread_count" - ) as mock_count, patch( - "bookwyrm.activitystreams.ActivityStream.get_unread_count_by_status_type" - ) as mock_count_by_status: + with ( + patch( + "bookwyrm.activitystreams.ActivityStream.get_unread_count" + ) as mock_count, + patch( + "bookwyrm.activitystreams.ActivityStream.get_unread_count_by_status_type" + ) as mock_count_by_status, + ): mock_count.return_value = 3 mock_count_by_status.return_value = { "generated_note": 1, diff --git a/bookwyrm/tests/views/test_user.py b/bookwyrm/tests/views/test_user.py index d4e11ff2e..4b49f120e 100644 --- a/bookwyrm/tests/views/test_user.py +++ b/bookwyrm/tests/views/test_user.py @@ -18,9 +18,11 @@ class UserViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse", @@ -34,10 +36,10 @@ class UserViews(TestCase): self.book = models.Edition.objects.create( title="test", parent_work=models.Work.objects.create(title="test work") ) - with patch( - "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" - ), patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.add_book_statuses_task.delay" + with ( + patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"), + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), ): models.ShelfBook.objects.create( book=self.book, diff --git a/bookwyrm/tests/views/test_wellknown.py b/bookwyrm/tests/views/test_wellknown.py index 4617942fa..d8bf0d062 100644 --- a/bookwyrm/tests/views/test_wellknown.py +++ b/bookwyrm/tests/views/test_wellknown.py @@ -16,9 +16,11 @@ class WellknownViews(TestCase): @classmethod def setUpTestData(self): # pylint: disable=bad-classmethod-argument """we need basic test data and mocks""" - with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( - "bookwyrm.activitystreams.populate_stream_task.delay" - ), patch("bookwyrm.lists_stream.populate_lists_task.delay"): + with ( + patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), + patch("bookwyrm.activitystreams.populate_stream_task.delay"), + patch("bookwyrm.lists_stream.populate_lists_task.delay"), + ): self.local_user = models.User.objects.create_user( "mouse@local.com", "mouse@mouse.mouse",