Bracket-wrap calls to patch() for better readability

This commit is contained in:
Adeodato Simó 2024-03-17 19:46:30 -03:00
parent 8cf52e0a77
commit 1b9e0546e6
123 changed files with 883 additions and 559 deletions

View file

@ -31,9 +31,11 @@ class BaseActivity(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we're probably going to re-use this so why copy/paste""" """we're probably going to re-use this so why copy/paste"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -13,9 +13,11 @@ class Note(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create a shared user""" """create a shared user"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -18,9 +18,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )
@ -105,9 +107,11 @@ class Activitystreams(TestCase):
privacy="direct", privacy="direct",
book=self.book, book=self.book,
) )
with patch("bookwyrm.activitystreams.r.set"), patch( with (
"bookwyrm.activitystreams.r.delete" patch("bookwyrm.activitystreams.r.set"),
), patch("bookwyrm.activitystreams.ActivityStream.get_store") as redis_mock: patch("bookwyrm.activitystreams.r.delete"),
patch("bookwyrm.activitystreams.ActivityStream.get_store") as redis_mock,
):
redis_mock.return_value = [status.id, status2.id] redis_mock.return_value = [status.id, status2.id]
result = self.test_stream.get_activity_stream(self.local_user) result = self.test_stream.get_activity_stream(self.local_user)
self.assertEqual(result.count(), 2) self.assertEqual(result.count(), 2)

View file

@ -17,9 +17,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -15,9 +15,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -15,9 +15,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -17,9 +17,11 @@ class ActivitystreamsSignals(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -10,9 +10,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -212,11 +212,14 @@ class Inventaire(TestCase):
json={"entities": {}}, json={"entities": {}},
) )
data = {"uri": "blah"} data = {"uri": "blah"}
with patch( with (
patch(
"bookwyrm.connectors.inventaire.Connector.load_edition_data" "bookwyrm.connectors.inventaire.Connector.load_edition_data"
) as loader_mock, patch( ) as loader_mock,
patch(
"bookwyrm.connectors.inventaire.Connector.get_book_data" "bookwyrm.connectors.inventaire.Connector.get_book_data"
) as getter_mock: ) as getter_mock,
):
loader_mock.return_value = {"uris": ["hello"]} loader_mock.return_value = {"uris": ["hello"]}
self.connector.get_edition_from_work_data(data) self.connector.get_edition_from_work_data(data)
self.assertTrue(getter_mock.called) self.assertTrue(getter_mock.called)

View file

@ -25,9 +25,11 @@ class CalibreImport(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -32,9 +32,11 @@ class GoodreadsImport(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -35,9 +35,11 @@ class GenericImporter(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -34,9 +34,11 @@ class LibrarythingImport(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mmai", "mmai@mmai.mmai", "password", local=True "mmai", "mmai@mmai.mmai", "password", local=True
) )

View file

@ -32,9 +32,11 @@ class OpenLibraryImport(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -32,9 +32,11 @@ class StorygraphImport(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""populate database""" """populate database"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -11,9 +11,11 @@ class ListsStreamSignals(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""database setup""" """database setup"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -18,9 +18,11 @@ class ListsStream(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""database setup""" """database setup"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -13,9 +13,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""database setup""" """database setup"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )
@ -36,9 +38,10 @@ class Activitystreams(TestCase):
inbox="https://example.com/users/rat/inbox", inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox", outbox="https://example.com/users/rat/outbox",
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create( self.list = models.List.objects.create(
user=self.local_user, name="hi", privacy="public" user=self.local_user, name="hi", privacy="public"
) )

View file

@ -15,9 +15,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need some stuff""" """we need some stuff"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -13,9 +13,11 @@ class Activitystreams(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need some stuff""" """we need some stuff"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "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 user=self.local_user, content="hi", book=self.book
) )
with patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.activitystreams.populate_stream_task.delay") as redis_mock,
) as redis_mock, patch( patch("bookwyrm.lists_stream.populate_lists_task.delay") as list_mock,
"bookwyrm.lists_stream.populate_lists_task.delay" ):
) as list_mock:
populate_streams() populate_streams()
self.assertEqual(redis_mock.call_count, 6) # 2 users x 3 streams self.assertEqual(redis_mock.call_count, 6) # 2 users x 3 streams
self.assertEqual(list_mock.call_count, 2) # 2 users self.assertEqual(list_mock.call_count, 2) # 2 users

View file

@ -29,9 +29,11 @@ class ActivitypubMixins(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""shared data""" """shared data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
) )

View file

@ -17,9 +17,11 @@ class AutomodModel(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class BaseModel(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""shared data""" """shared data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
) )

View file

@ -16,16 +16,14 @@ class BookwyrmExport(TestCase):
def setUp(self): def setUp(self):
"""lots of stuff to set up for a user export""" """lots of stuff to set up for a user export"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"), patch( patch("bookwyrm.activitystreams.populate_stream_task.delay"),
"bookwyrm.suggested_users.rerank_user_task.delay" patch("bookwyrm.lists_stream.populate_lists_task.delay"),
), patch( patch("bookwyrm.suggested_users.rerank_user_task.delay"),
"bookwyrm.lists_stream.remove_list_task.delay" patch("bookwyrm.lists_stream.remove_list_task.delay"),
), patch( patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.activitystreams.add_book_statuses_task"),
), patch(
"bookwyrm.activitystreams.add_book_statuses_task"
): ):
self.local_user = models.User.objects.create_user( self.local_user = models.User.objects.create_user(

View file

@ -18,10 +18,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods
def setUp(self): def setUp(self):
"""setting stuff up""" """setting stuff up"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"), patch( patch("bookwyrm.activitystreams.populate_stream_task.delay"),
"bookwyrm.suggested_users.rerank_user_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( 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): def test_update_user_profile(self):
"""Test update the user's profile from import data""" """Test update the user's profile from import data"""
with patch("bookwyrm.suggested_users.remove_user_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.suggested_users.remove_user_task.delay"),
), patch("bookwyrm.suggested_users.rerank_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 open(self.archive_file, "rb") as fileobj:
with BookwyrmTarFile.open(mode="r:gz", fileobj=fileobj) as tarfile: 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): def test_update_user_settings(self):
"""Test updating the user's settings from import data""" """Test updating the user's settings from import data"""
with patch("bookwyrm.suggested_users.remove_user_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.suggested_users.remove_user_task.delay"),
), patch("bookwyrm.suggested_users.rerank_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( models.bookwyrm_import_job.update_user_settings(
self.local_user, self.json_data 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): def test_upsert_saved_lists_existing(self):
"""Test upserting an existing saved list""" """Test upserting an existing saved list"""
with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.lists_stream.remove_list_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
book_list = models.List.objects.create( book_list = models.List.objects.create(
name="My cool list", 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): def test_upsert_saved_lists_not_existing(self):
"""Test upserting a new saved list""" """Test upserting a new saved list"""
with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.lists_stream.remove_list_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
book_list = models.List.objects.create( book_list = models.List.objects.create(
name="My cool list", name="My cool list",
@ -199,9 +206,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods
self.assertFalse(before_follow) self.assertFalse(before_follow)
with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), patch( with (
"bookwyrm.lists_stream.add_user_lists_task.delay" patch("bookwyrm.activitystreams.add_user_statuses_task.delay"),
), patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): patch("bookwyrm.lists_stream.add_user_lists_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
):
models.bookwyrm_import_job.upsert_follows( models.bookwyrm_import_job.upsert_follows(
self.local_user, self.json_data.get("follows") self.local_user, self.json_data.get("follows")
) )
@ -222,10 +231,11 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods
).exists() ).exists()
self.assertFalse(blocked_before) self.assertFalse(blocked_before)
with patch("bookwyrm.suggested_users.remove_suggestion_task.delay"), patch( with (
"bookwyrm.activitystreams.remove_user_statuses_task.delay" patch("bookwyrm.suggested_users.remove_suggestion_task.delay"),
), patch("bookwyrm.lists_stream.remove_user_lists_task.delay"), patch( patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"),
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" 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( models.bookwyrm_import_job.upsert_user_blocks(
self.local_user, self.json_data.get("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) self.assertEqual(models.Review.objects.filter(user=self.local_user).count(), 0)
reviews = self.json_data["books"][0]["reviews"] reviews = self.json_data["books"][0]["reviews"]
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True),
):
bookwyrm_import_job.upsert_statuses( bookwyrm_import_job.upsert_statuses(
self.local_user, models.Review, reviews, self.book.remote_id 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) self.assertEqual(models.Comment.objects.filter(user=self.local_user).count(), 0)
comments = self.json_data["books"][1]["comments"] comments = self.json_data["books"][1]["comments"]
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True),
):
bookwyrm_import_job.upsert_statuses( bookwyrm_import_job.upsert_statuses(
self.local_user, models.Comment, comments, self.book.remote_id 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 models.Quotation.objects.filter(user=self.local_user).count(), 0
) )
quotes = self.json_data["books"][1]["quotations"] quotes = self.json_data["books"][1]["quotations"]
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True): patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=True),
):
bookwyrm_import_job.upsert_statuses( bookwyrm_import_job.upsert_statuses(
self.local_user, models.Quotation, quotes, self.book.remote_id 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 models.Quotation.objects.filter(user=self.local_user).count(), 0
) )
quotes = self.json_data["books"][1]["quotations"] quotes = self.json_data["books"][1]["quotations"]
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=False): patch("bookwyrm.models.bookwyrm_import_job.is_alias", return_value=False),
):
bookwyrm_import_job.upsert_statuses( bookwyrm_import_job.upsert_statuses(
self.local_user, models.Quotation, quotes, self.book.remote_id 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" title="Another Book", remote_id="https://example.com/book/9876"
) )
with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.lists_stream.remove_list_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
book_list = models.List.objects.create( book_list = models.List.objects.create(
name="my list of books", user=self.local_user name="my list of books", user=self.local_user
@ -452,8 +467,9 @@ class BookwyrmImport(TestCase): # pylint: disable=too-many-public-methods
1, 1,
) )
with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.lists_stream.remove_list_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
bookwyrm_import_job.upsert_lists( bookwyrm_import_job.upsert_lists(
self.local_user, 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.assertEqual(models.List.objects.filter(user=self.local_user).count(), 0)
self.assertFalse(models.ListItem.objects.filter(book=self.book.id).exists()) self.assertFalse(models.ListItem.objects.filter(book=self.book.id).exists())
with patch("bookwyrm.lists_stream.remove_list_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.lists_stream.remove_list_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
bookwyrm_import_job.upsert_lists( bookwyrm_import_job.upsert_lists(
self.local_user, 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) shelf = models.Shelf.objects.get(name="Read", user=self.local_user)
with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.activitystreams.add_book_statuses_task.delay"),
patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
): ):
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
book=self.book, shelf=shelf, user=self.local_user book=self.book, shelf=shelf, user=self.local_user
) )
book_data = self.json_data["books"][0] book_data = self.json_data["books"][0]
with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" 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) 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] book_data = self.json_data["books"][0]
with patch("bookwyrm.activitystreams.add_book_statuses_task.delay"), patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" 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) bookwyrm_import_job.upsert_shelves(self.book, self.local_user, book_data)

View file

@ -13,9 +13,11 @@ class Group(TestCase):
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""Set up for tests""" """Set up for tests"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.owner_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "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 """follower-only group booklists should not be excluded from group booklist
listing for group members who do not follower list owner""" listing for group members who do not follower list owner"""
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
followers_list = models.List.objects.create( followers_list = models.List.objects.create(
name="Followers List", name="Followers List",
curation="group", curation="group",
@ -104,9 +107,10 @@ class Group(TestCase):
"""private group booklists should not be excluded from group booklist listing """private group booklists should not be excluded from group booklist listing
for group members""" for group members"""
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
private_list = models.List.objects.create( private_list = models.List.objects.create(
name="Private List", name="Private List",
privacy="direct", privacy="direct",

View file

@ -19,9 +19,11 @@ class ImportJob(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""data is from a goodreads export of The Raven Tower""" """data is from a goodreads export of The Raven Tower"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True "mouse", "mouse@mouse.mouse", "password", local=True
) )

View file

@ -14,9 +14,11 @@ class List(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""look, a list""" """look, a list"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -10,9 +10,11 @@ class Notification(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""useful things for creating a notification""" """useful things for creating a notification"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )
@ -201,9 +203,11 @@ class NotifyInviteRequest(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""ensure there is one admin""" """ensure there is one admin"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -264,9 +268,11 @@ class NotifyInviteRequest(TestCase):
def test_notify_multiple_admins(self): def test_notify_multiple_admins(self):
"""all admins are notified""" """all admins are notified"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"admin@local.com", "admin@local.com",
"admin@example.com", "admin@example.com",

View file

@ -14,9 +14,11 @@ class ReadThrough(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""look, a shelf""" """look, a shelf"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -27,9 +27,11 @@ class Relationship(TestCase):
inbox="https://example.com/users/rat/inbox", inbox="https://example.com/users/rat/inbox",
outbox="https://example.com/users/rat/outbox", outbox="https://example.com/users/rat/outbox",
) )
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
) )

View file

@ -18,9 +18,11 @@ class Shelf(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""look, a shelf""" """look, a shelf"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -15,9 +15,11 @@ class SiteModels(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -27,9 +27,11 @@ class Status(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""useful things for creating a status""" """useful things for creating a status"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "mouseword", local=True, localname="mouse"
) )

View file

@ -20,9 +20,11 @@ class User(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
f"mouse@{DOMAIN}", f"mouse@{DOMAIN}",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -122,9 +124,11 @@ class User(TestCase):
site.default_user_auth_group = Group.objects.get(name="editor") site.default_user_auth_group = Group.objects.get(name="editor")
site.save() site.save()
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
user = models.User.objects.create_user( user = models.User.objects.create_user(
f"test2{DOMAIN}", f"test2{DOMAIN}",
"test2@bookwyrm.test", "test2@bookwyrm.test",
@ -135,9 +139,11 @@ class User(TestCase):
site.default_user_auth_group = None site.default_user_auth_group = None
site.save() site.save()
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
user = models.User.objects.create_user( user = models.User.objects.create_user(
f"test1{DOMAIN}", f"test1{DOMAIN}",
"test1@bookwyrm.test", "test1@bookwyrm.test",
@ -228,11 +234,14 @@ class User(TestCase):
self.assertEqual(self.user.name, "hi") self.assertEqual(self.user.name, "hi")
self.assertEqual(self.user.summary, "a summary") self.assertEqual(self.user.summary, "a summary")
self.assertEqual(self.user.email, "mouse@mouse.mouse") self.assertEqual(self.user.email, "mouse@mouse.mouse")
with patch( with (
patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as broadcast_mock, patch( ) as broadcast_mock,
patch(
"bookwyrm.models.user.User.erase_user_statuses" "bookwyrm.models.user.User.erase_user_statuses"
) as erase_statuses_mock: ) as erase_statuses_mock,
):
self.user.delete() self.user.delete()
self.assertEqual(erase_statuses_mock.call_count, 1) self.assertEqual(erase_statuses_mock.call_count, 1)

View file

@ -16,9 +16,11 @@ class BookDisplayTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class FeedPageTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class InteractionTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class NotificationPageTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class RatingTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class ShelfTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class StatusDisplayTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class UtilitiesTags(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create some filler objects""" """create some filler objects"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.user = models.User.objects.create_user( self.user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -14,9 +14,11 @@ class ContextProcessor(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -14,9 +14,11 @@ class Emailing(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -31,9 +31,11 @@ class PreviewImages(TestCase):
avatar_file = pathlib.Path(__file__).parent.joinpath( avatar_file = pathlib.Path(__file__).parent.joinpath(
"../static/images/no_cover.jpg" "../static/images/no_cover.jpg"
) )
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"possum@local.com", "possum@local.com",
"possum@possum.possum", "possum@possum.possum",
@ -47,9 +49,11 @@ class PreviewImages(TestCase):
), ),
) )
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.remote_user = models.User.objects.create_user(
"rat", "rat",
"rat@rat.com", "rat@rat.com",
@ -60,9 +64,11 @@ class PreviewImages(TestCase):
outbox="https://example.com/users/rat/outbox", outbox="https://example.com/users/rat/outbox",
) )
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.remote_user_with_preview = models.User.objects.create_user(
"badger@your.domain.here", "badger@your.domain.here",
"badger@badger.com", "badger@badger.com",

View file

@ -38,9 +38,11 @@ class Signature(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""create users and test data""" """create users and test data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
self.mouse = models.User.objects.create_user( self.mouse = models.User.objects.create_user(
f"mouse@{DOMAIN}", f"mouse@{DOMAIN}",
"mouse@example.com", "mouse@example.com",

View file

@ -22,9 +22,11 @@ class SuggestedUsers(TestCase):
def setUp(self): def setUp(self):
"""use a test csv""" """use a test csv"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse" "mouse", "mouse@mouse.mouse", "password", local=True, localname="mouse"
) )

View file

@ -14,9 +14,11 @@ class AnnouncementViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class AutomodViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class CeleryStatusViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class DashboardViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class EmailBlocklistViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class EmailConfigViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -20,9 +20,11 @@ class FederationViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class ImportsAdminViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class IPBlocklistViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class LinkDomainViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class ReportViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class SiteSettingsViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class AdminThemesViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class UserAdminViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -26,9 +26,11 @@ class BookViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -22,9 +22,11 @@ class EditBookViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -16,9 +16,11 @@ class BookViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -18,8 +18,9 @@ class LinkViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
): ):
self.local_user = models.User.objects.create_user( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",

View file

@ -19,9 +19,11 @@ class ImportViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -14,9 +14,11 @@ class ImportManualReviewViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -15,9 +15,11 @@ class ImportTroubleshootViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -18,9 +18,11 @@ class ImportUserViews(TestCase):
def setUp(self): def setUp(self):
"""we need basic test data and mocks""" """we need basic test data and mocks"""
self.factory = RequestFactory() self.factory = RequestFactory()
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -31,9 +31,11 @@ class Inbox(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
local_user = models.User.objects.create_user( local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -14,9 +14,11 @@ class InboxAdd(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_task.delay"): patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
local_user = models.User.objects.create_user( local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -14,9 +14,11 @@ class InboxActivities(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -13,9 +13,11 @@ class InboxBlock(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -56,9 +58,12 @@ class InboxBlock(TestCase):
"object": "https://example.com/user/mouse", "object": "https://example.com/user/mouse",
} }
with patch( with (
patch(
"bookwyrm.activitystreams.remove_user_statuses_task.delay" "bookwyrm.activitystreams.remove_user_statuses_task.delay"
) as redis_mock, patch("bookwyrm.lists_stream.remove_user_lists_task.delay"): ) as redis_mock,
patch("bookwyrm.lists_stream.remove_user_lists_task.delay"),
):
views.inbox.activity_task(activity) views.inbox.activity_task(activity)
self.assertTrue(redis_mock.called) self.assertTrue(redis_mock.called)
views.inbox.activity_task(activity) views.inbox.activity_task(activity)

View file

@ -15,9 +15,11 @@ class TransactionInboxCreate(TransactionTestCase):
def setUp(self): def setUp(self):
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -74,9 +76,11 @@ class InboxCreate(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -14,9 +14,11 @@ class InboxActivities(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -14,9 +14,11 @@ class InboxRelationships(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -13,9 +13,11 @@ class InboxActivities(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -13,9 +13,11 @@ class InboxRemove(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -76,9 +78,10 @@ class InboxRemove(TestCase):
def test_handle_remove_book_from_list(self): def test_handle_remove_book_from_list(self):
"""listing a book""" """listing a book"""
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
booklist = models.List.objects.create( booklist = models.List.objects.create(
name="test list", name="test list",
user=self.local_user, user=self.local_user,

View file

@ -15,9 +15,11 @@ class InboxUpdate(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""basic user and book data""" """basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -53,9 +55,10 @@ class InboxUpdate(TestCase):
def test_update_list(self): def test_update_list(self):
"""a new list""" """a new list"""
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
book_list = models.List.objects.create( book_list = models.List.objects.create(
name="hi", remote_id="https://example.com/list/22", user=self.local_user name="hi", remote_id="https://example.com/list/22", user=self.local_user
) )

View file

@ -17,9 +17,11 @@ class InviteViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -17,9 +17,11 @@ class LandingViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",

View file

@ -20,9 +20,11 @@ class LoginViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@your.domain.here", "mouse@your.domain.here",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -19,9 +19,11 @@ class PasswordViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -23,9 +23,11 @@ class RegisterViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@your.domain.here", "mouse@your.domain.here",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -18,9 +18,11 @@ class ListViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -36,9 +38,10 @@ class ListViews(TestCase):
parent_work=work, parent_work=work,
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create( self.list = models.List.objects.create(
name="Test List", user=self.local_user name="Test List", user=self.local_user
) )

View file

@ -18,9 +18,11 @@ class ListViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -36,9 +38,10 @@ class ListViews(TestCase):
parent_work=work, parent_work=work,
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create( self.list = models.List.objects.create(
name="Test List", user=self.local_user name="Test List", user=self.local_user
) )

View file

@ -21,9 +21,11 @@ class ListViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -65,9 +67,10 @@ class ListViews(TestCase):
parent_work=work_four, parent_work=work_four,
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create( self.list = models.List.objects.create(
name="Test List", user=self.local_user name="Test List", user=self.local_user
) )
@ -248,9 +251,12 @@ class ListViews(TestCase):
) )
request.user = self.local_user request.user = self.local_user
with patch( with (
patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay"): ) as mock,
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
result = view(request, self.list.id) result = view(request, self.list.id)
self.assertEqual(mock.call_count, 1) self.assertEqual(mock.call_count, 1)
@ -286,9 +292,12 @@ class ListViews(TestCase):
) )
request = self.factory.post("") request = self.factory.post("")
request.user = self.local_user request.user = self.local_user
with patch( with (
patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay") as redis_mock: ) as mock,
patch("bookwyrm.lists_stream.remove_list_task.delay") as redis_mock,
):
views.delete_list(request, self.list.id) views.delete_list(request, self.list.id)
self.assertTrue(redis_mock.called) self.assertTrue(redis_mock.called)
activity = json.loads(mock.call_args[1]["args"][1]) activity = json.loads(mock.call_args[1]["args"][1])

View file

@ -15,9 +15,11 @@ class ListItemViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -32,9 +34,10 @@ class ListItemViews(TestCase):
remote_id="https://example.com/book/1", remote_id="https://example.com/book/1",
parent_work=work, parent_work=work,
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
self.list = models.List.objects.create( self.list = models.List.objects.create(
name="Test List", user=self.local_user name="Test List", user=self.local_user
) )

View file

@ -18,9 +18,11 @@ class ListViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",
@ -45,10 +47,10 @@ class ListViews(TestCase):
def test_lists_page(self, _): def test_lists_page(self, _):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
view = views.Lists.as_view() view = views.Lists.as_view()
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.add_list_task.delay"), patch( patch("bookwyrm.lists_stream.add_list_task.delay"),
"bookwyrm.lists_stream.remove_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(name="Public list", user=self.local_user)
models.List.objects.create( models.List.objects.create(
@ -72,9 +74,10 @@ class ListViews(TestCase):
def test_saved_lists_page(self): def test_saved_lists_page(self):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
view = views.SavedLists.as_view() view = views.SavedLists.as_view()
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_list_task.delay"): patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
booklist = models.List.objects.create( booklist = models.List.objects.create(
name="Public list", user=self.local_user name="Public list", user=self.local_user
) )
@ -94,9 +97,10 @@ class ListViews(TestCase):
def test_saved_lists_page_empty(self): def test_saved_lists_page_empty(self):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
view = views.SavedLists.as_view() view = views.SavedLists.as_view()
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_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(name="Public list", user=self.local_user)
models.List.objects.create( models.List.objects.create(
name="Private list", privacy="direct", user=self.local_user name="Private list", privacy="direct", user=self.local_user
@ -122,9 +126,10 @@ class ListViews(TestCase):
def test_user_lists_page(self): def test_user_lists_page(self):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
view = views.UserLists.as_view() view = views.UserLists.as_view()
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.lists_stream.remove_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(name="Public list", user=self.local_user)
models.List.objects.create( models.List.objects.create(
name="Private list", privacy="direct", user=self.local_user name="Private list", privacy="direct", user=self.local_user
@ -160,9 +165,12 @@ class ListViews(TestCase):
}, },
) )
request.user = self.local_user request.user = self.local_user
with patch( with (
patch(
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" "bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"
) as mock, patch("bookwyrm.lists_stream.remove_list_task.delay"): ) as mock,
patch("bookwyrm.lists_stream.remove_list_task.delay"),
):
result = view(request) result = view(request)
self.assertEqual(mock.call_count, 1) self.assertEqual(mock.call_count, 1)

View file

@ -16,9 +16,11 @@ class BlockViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -65,8 +67,9 @@ class BlockViews(TestCase):
request = self.factory.post("") request = self.factory.post("")
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"), patch( with (
"bookwyrm.lists_stream.remove_user_lists_task.delay" patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"),
patch("bookwyrm.lists_stream.remove_user_lists_task.delay"),
): ):
view(request, self.remote_user.id) view(request, self.remote_user.id)
block = models.UserBlocks.objects.get() block = models.UserBlocks.objects.get()
@ -82,8 +85,9 @@ class BlockViews(TestCase):
request = self.factory.post("") request = self.factory.post("")
request.user = self.local_user request.user = self.local_user
with patch("bookwyrm.activitystreams.add_user_statuses_task.delay"), patch( with (
"bookwyrm.lists_stream.add_user_lists_task.delay" patch("bookwyrm.activitystreams.add_user_statuses_task.delay"),
patch("bookwyrm.lists_stream.add_user_lists_task.delay"),
): ):
views.unblock(request, self.remote_user.id) views.unblock(request, self.remote_user.id)

View file

@ -15,9 +15,11 @@ class ChangePasswordViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -19,9 +19,11 @@ class DeleteUserViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@your.domain.here", "mouse@your.domain.here",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -40,9 +42,10 @@ class DeleteUserViews(TestCase):
self.book = models.Edition.objects.create( self.book = models.Edition.objects.create(
title="test", parent_work=models.Work.objects.create(title="test work") title="test", parent_work=models.Work.objects.create(title="test work")
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"): patch("bookwyrm.activitystreams.add_book_statuses_task.delay"),
):
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
book=self.book, book=self.book,
user=self.local_user, user=self.local_user,

View file

@ -21,9 +21,11 @@ class EditUserViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.mouse", "mouse@mouse.mouse",
@ -38,9 +40,10 @@ class EditUserViews(TestCase):
self.book = models.Edition.objects.create( self.book = models.Edition.objects.create(
title="test", parent_work=models.Work.objects.create(title="test work") title="test", parent_work=models.Work.objects.create(title="test work")
) )
with patch( with (
"bookwyrm.models.activitypub_mixin.broadcast_task.apply_async" patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"),
), patch("bookwyrm.activitystreams.add_book_statuses_task.delay"): patch("bookwyrm.activitystreams.add_book_statuses_task.delay"),
):
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
book=self.book, book=self.book,
user=self.local_user, user=self.local_user,

View file

@ -22,8 +22,9 @@ class ExportViews(TestCase):
self, self,
): # pylint: disable=bad-classmethod-argument, disable=invalid-name ): # pylint: disable=bad-classmethod-argument, disable=invalid-name
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
): ):
self.local_user = models.User.objects.create_user( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",

View file

@ -15,8 +15,9 @@ class ExportUserViews(TestCase):
def setUp(self): def setUp(self):
self.factory = RequestFactory() self.factory = RequestFactory()
models.SiteSettings.objects.create() models.SiteSettings.objects.create()
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
): ):
self.local_user = models.User.objects.create_user( self.local_user = models.User.objects.create_user(
"hugh@example.com", "hugh@example.com",

View file

@ -20,9 +20,11 @@ class TwoFactorViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@your.domain.here", "mouse@your.domain.here",
"mouse@mouse.com", "mouse@mouse.com",
@ -130,8 +132,9 @@ class TwoFactorViews(TestCase):
request.session["2fa_user"] = self.local_user.username request.session["2fa_user"] = self.local_user.username
request.session.save() request.session.save()
with patch("bookwyrm.views.preferences.two_factor_auth.LoginWith2FA"), patch( with (
"bookwyrm.views.preferences.two_factor_auth.login" patch("bookwyrm.views.preferences.two_factor_auth.LoginWith2FA"),
patch("bookwyrm.views.preferences.two_factor_auth.login"),
): ):
result = view(request) result = view(request)
self.assertEqual(result.url, "/") self.assertEqual(result.url, "/")

View file

@ -23,9 +23,11 @@ class ShelfViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -21,9 +21,11 @@ class ShelfActionViews(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

View file

@ -24,9 +24,11 @@ class AnnualSummary(TestCase):
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(self): # pylint: disable=bad-classmethod-argument
"""we need basic test data and mocks""" """we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch( with (
"bookwyrm.activitystreams.populate_stream_task.delay" patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
), patch("bookwyrm.lists_stream.populate_lists_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( self.local_user = models.User.objects.create_user(
"mouse@local.com", "mouse@local.com",
"mouse@mouse.com", "mouse@mouse.com",

Some files were not shown because too many files have changed in this diff Show more