Skip to content

Commit

Permalink
Update to match newer code style
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSchuurmans committed Apr 24, 2024
1 parent 839ab2f commit f24fdf7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
20 changes: 11 additions & 9 deletions bookwyrm/tests/models/test_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -23,16 +23,18 @@ def setUpTestData(self): # pylint: disable=bad-classmethod-argument
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):
Expand Down
22 changes: 12 additions & 10 deletions bookwyrm/tests/views/preferences/test_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
@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",
Expand All @@ -37,10 +38,11 @@ def setUpTestData(self): # pylint: disable=bad-classmethod-argument
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",
Expand Down

0 comments on commit f24fdf7

Please sign in to comment.