mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-07 15:55:29 +00:00
Updates inbox tests
This commit is contained in:
parent
7a89552892
commit
93dbe2daa0
10 changed files with 22 additions and 16 deletions
|
@ -22,7 +22,7 @@ class Inbox(TestCase):
|
||||||
|
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -15,7 +15,7 @@ class InboxAdd(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -15,7 +15,7 @@ class InboxActivities(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -14,7 +14,7 @@ class InboxBlock(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
@ -57,7 +57,7 @@ class InboxBlock(TestCase):
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.activitystreams.remove_user_statuses_task.delay"
|
"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)
|
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)
|
||||||
|
@ -70,7 +70,9 @@ class InboxBlock(TestCase):
|
||||||
self.assertFalse(models.UserFollowRequest.objects.exists())
|
self.assertFalse(models.UserFollowRequest.objects.exists())
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.remove_user_statuses_task.delay")
|
@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"""
|
"""unblock a user"""
|
||||||
self.remote_user.blocks.add(self.local_user)
|
self.remote_user.blocks.add(self.local_user)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class InboxCreate(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -15,7 +15,7 @@ class InboxActivities(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
@ -51,7 +51,7 @@ class InboxActivities(TestCase):
|
||||||
"type": "Delete",
|
"type": "Delete",
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"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,
|
"actor": self.remote_user.remote_id,
|
||||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class InboxActivities(TestCase):
|
||||||
"type": "Delete",
|
"type": "Delete",
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||||
"cc": ["https://example.com/user/mouse/followers"],
|
"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,
|
"actor": self.remote_user.remote_id,
|
||||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||||
}
|
}
|
||||||
|
@ -152,5 +152,7 @@ class InboxActivities(TestCase):
|
||||||
"cc": [],
|
"cc": [],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
with patch("bookwyrm.lists_stream.remove_list_task.delay") as mock:
|
||||||
views.inbox.activity_task(activity)
|
views.inbox.activity_task(activity)
|
||||||
|
self.assertTrue(mock.called)
|
||||||
self.assertFalse(models.List.objects.exists())
|
self.assertFalse(models.List.objects.exists())
|
||||||
|
|
|
@ -15,7 +15,7 @@ class InboxRelationships(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
@ -188,7 +188,8 @@ class InboxRelationships(TestCase):
|
||||||
self.assertIsNone(self.local_user.followers.first())
|
self.assertIsNone(self.local_user.followers.first())
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
@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"""
|
"""a remote user approved a follow request from local"""
|
||||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
|
||||||
rel = models.UserFollowRequest.objects.create(
|
rel = models.UserFollowRequest.objects.create(
|
||||||
|
|
|
@ -14,7 +14,7 @@ class InboxActivities(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -14,7 +14,7 @@ class InboxRemove(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
|
|
@ -16,7 +16,7 @@ class InboxUpdate(TestCase):
|
||||||
"""basic user and book data"""
|
"""basic user and book data"""
|
||||||
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"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",
|
||||||
|
@ -78,6 +78,7 @@ class InboxUpdate(TestCase):
|
||||||
|
|
||||||
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
|
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||||
|
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
|
||||||
def test_update_user(self, *_):
|
def test_update_user(self, *_):
|
||||||
"""update an existing user"""
|
"""update an existing user"""
|
||||||
models.UserFollows.objects.create(
|
models.UserFollows.objects.create(
|
||||||
|
|
Loading…
Reference in a new issue