Updates inbox tests

This commit is contained in:
Mouse Reeve 2021-12-09 15:02:53 -08:00
parent 7a89552892
commit 93dbe2daa0
10 changed files with 22 additions and 16 deletions

View file

@ -22,7 +22,7 @@ class Inbox(TestCase):
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -15,7 +15,7 @@ class InboxAdd(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -15,7 +15,7 @@ class InboxActivities(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -14,7 +14,7 @@ class InboxBlock(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
@ -57,7 +57,7 @@ class InboxBlock(TestCase):
with patch(
"bookwyrm.activitystreams.remove_user_statuses_task.delay"
) as redis_mock:
) as redis_mock, patch("bookwyrm.lists_stream.remove_user_lists_task.delay"):
views.inbox.activity_task(activity)
self.assertTrue(redis_mock.called)
views.inbox.activity_task(activity)
@ -70,7 +70,9 @@ class InboxBlock(TestCase):
self.assertFalse(models.UserFollowRequest.objects.exists())
@patch("bookwyrm.activitystreams.remove_user_statuses_task.delay")
def test_handle_unblock(self, _):
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
@patch("bookwyrm.lists_stream.remove_user_lists_task.delay")
def test_handle_unblock(self, *_):
"""unblock a user"""
self.remote_user.blocks.add(self.local_user)

View file

@ -19,7 +19,7 @@ class InboxCreate(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -15,7 +15,7 @@ class InboxActivities(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
@ -51,7 +51,7 @@ class InboxActivities(TestCase):
"type": "Delete",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/user/mouse/followers"],
"id": "%s/activity" % self.status.remote_id,
"id": f"{self.status.remote_id}/activity",
"actor": self.remote_user.remote_id,
"object": {"id": self.status.remote_id, "type": "Tombstone"},
}
@ -80,7 +80,7 @@ class InboxActivities(TestCase):
"type": "Delete",
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/user/mouse/followers"],
"id": "%s/activity" % self.status.remote_id,
"id": f"{self.status.remote_id}/activity",
"actor": self.remote_user.remote_id,
"object": {"id": self.status.remote_id, "type": "Tombstone"},
}
@ -152,5 +152,7 @@ class InboxActivities(TestCase):
"cc": [],
},
}
views.inbox.activity_task(activity)
with patch("bookwyrm.lists_stream.remove_list_task.delay") as mock:
views.inbox.activity_task(activity)
self.assertTrue(mock.called)
self.assertFalse(models.List.objects.exists())

View file

@ -15,7 +15,7 @@ class InboxRelationships(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
@ -188,7 +188,8 @@ class InboxRelationships(TestCase):
self.assertIsNone(self.local_user.followers.first())
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
def test_follow_accept(self, _):
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
def test_follow_accept(self, *_):
"""a remote user approved a follow request from local"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
rel = models.UserFollowRequest.objects.create(

View file

@ -14,7 +14,7 @@ class InboxActivities(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -14,7 +14,7 @@ class InboxRemove(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",

View file

@ -16,7 +16,7 @@ class InboxUpdate(TestCase):
"""basic user and book data"""
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
):
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse@example.com",
"mouse@mouse.com",
@ -78,6 +78,7 @@ class InboxUpdate(TestCase):
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
def test_update_user(self, *_):
"""update an existing user"""
models.UserFollows.objects.create(