Update to match newer code style

This commit is contained in:
Bart Schuurmans 2024-04-24 15:02:05 +02:00
parent 839ab2fafd
commit f24fdf73b5
2 changed files with 23 additions and 19 deletions

View file

@ -10,10 +10,10 @@ class MoveUser(TestCase):
"""move your account to another identity""" """move your account to another identity"""
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(cls):
"""we need some users for this""" """we need some users for this"""
with patch("bookwyrm.models.user.set_remote_server.delay"): with patch("bookwyrm.models.user.set_remote_server.delay"):
self.target_user = models.User.objects.create_user( cls.target_user = models.User.objects.create_user(
"rat", "rat",
"rat@rat.com", "rat@rat.com",
"ratword", "ratword",
@ -23,16 +23,18 @@ class MoveUser(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"),
self.origin_user = models.User.objects.create_user( patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
cls.origin_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse" "mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
) )
self.origin_user.remote_id = "http://local.com/user/mouse" cls.origin_user.remote_id = "http://local.com/user/mouse"
self.origin_user.save(broadcast=False, update_fields=["remote_id"]) cls.origin_user.save(broadcast=False, update_fields=["remote_id"])
def test_user_move_unauthorized(self, *_): def test_user_move_unauthorized(self):
"""attempt a user move without alsoKnownAs set""" """attempt a user move without alsoKnownAs set"""
with self.assertRaises(PermissionDenied): with self.assertRaises(PermissionDenied):

View file

@ -14,20 +14,21 @@ from bookwyrm import forms, models, views
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
@patch("bookwyrm.activitystreams.populate_stream_task.delay") @patch("bookwyrm.activitystreams.populate_stream_task.delay")
@patch("bookwyrm.suggested_users.rerank_user_task.delay") @patch("bookwyrm.suggested_users.rerank_user_task.delay")
class ViewsHelpers(TestCase): # pylint: disable=too-many-public-methods class ViewsHelpers(TestCase):
"""viewing and creating statuses""" """viewing and creating statuses"""
@classmethod @classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument def setUpTestData(cls):
"""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( 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( cls.local_user = models.User.objects.create_user(
"rat", "rat",
"rat@rat.com", "rat@rat.com",
"ratword", "ratword",
@ -37,10 +38,11 @@ class ViewsHelpers(TestCase): # pylint: disable=too-many-public-methods
remote_id="https://your.domain.here/user/rat", remote_id="https://your.domain.here/user/rat",
) )
with patch("bookwyrm.models.user.set_remote_server.delay"), patch( with (
"bookwyrm.suggested_users.rerank_user_task.delay" patch("bookwyrm.models.user.set_remote_server.delay"),
patch("bookwyrm.suggested_users.rerank_user_task.delay"),
): ):
self.remote_user = models.User.objects.create_user( cls.remote_user = models.User.objects.create_user(
"mouse@example.com", "mouse@example.com",
"mouse@mouse.com", "mouse@mouse.com",
"mouseword", "mouseword",