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"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need some users for this"""
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.com",
"ratword",
@ -23,16 +23,18 @@ class MoveUser(TestCase):
outbox="https://example.com/users/rat/outbox",
)
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.origin_user = models.User.objects.create_user(
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
):
cls.origin_user = models.User.objects.create_user(
"mouse", "mouse@mouse.com", "mouseword", local=True, localname="mouse"
)
self.origin_user.remote_id = "http://local.com/user/mouse"
self.origin_user.save(broadcast=False, update_fields=["remote_id"])
cls.origin_user.remote_id = "http://local.com/user/mouse"
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"""
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.activitystreams.populate_stream_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"""
@classmethod
def setUpTestData(self): # pylint: disable=bad-classmethod-argument
def setUpTestData(cls):
"""we need basic test data and mocks"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
), patch("bookwyrm.lists_stream.populate_lists_task.delay"), patch(
"bookwyrm.suggested_users.rerank_user_task.delay"
with (
patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"),
patch("bookwyrm.activitystreams.populate_stream_task.delay"),
patch("bookwyrm.lists_stream.populate_lists_task.delay"),
patch("bookwyrm.suggested_users.rerank_user_task.delay"),
):
self.local_user = models.User.objects.create_user(
cls.local_user = models.User.objects.create_user(
"rat",
"rat@rat.com",
"ratword",
@ -37,10 +38,11 @@ class ViewsHelpers(TestCase): # pylint: disable=too-many-public-methods
remote_id="https://your.domain.here/user/rat",
)
with patch("bookwyrm.models.user.set_remote_server.delay"), patch(
"bookwyrm.suggested_users.rerank_user_task.delay"
with (
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@mouse.com",
"mouseword",