another round of mocks
This commit is contained in:
@ -55,9 +55,8 @@ class InboxActivities(TestCase):
|
||||
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
|
||||
def test_boost(self, redis_mock, _):
|
||||
@patch("bookwyrm.activitystreams.handle_boost_task.delay")
|
||||
def test_boost(self, _):
|
||||
"""boost a status"""
|
||||
self.assertEqual(models.Notification.objects.count(), 0)
|
||||
activity = {
|
||||
@ -73,9 +72,6 @@ class InboxActivities(TestCase):
|
||||
discarder.return_value = False
|
||||
views.inbox.activity_task(activity)
|
||||
|
||||
# boost added to redis activitystreams
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
||||
# boost created of correct status
|
||||
boost = models.Boost.objects.get()
|
||||
self.assertEqual(boost.boosted_status, self.status)
|
||||
@ -86,9 +82,8 @@ class InboxActivities(TestCase):
|
||||
self.assertEqual(notification.related_status, self.status)
|
||||
|
||||
@responses.activate
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
|
||||
def test_boost_remote_status(self, redis_mock, _):
|
||||
@patch("bookwyrm.activitystreams.handle_boost_task.delay")
|
||||
def test_boost_remote_status(self, _):
|
||||
"""boost a status from a remote server"""
|
||||
work = models.Work.objects.create(title="work title")
|
||||
book = models.Edition.objects.create(
|
||||
@ -129,7 +124,6 @@ class InboxActivities(TestCase):
|
||||
with patch("bookwyrm.models.status.Status.ignore_activity") as discarder:
|
||||
discarder.return_value = False
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
||||
boost = models.Boost.objects.get()
|
||||
self.assertEqual(boost.boosted_status.remote_id, "https://remote.com/status/1")
|
||||
@ -161,7 +155,8 @@ class InboxActivities(TestCase):
|
||||
self.assertEqual(models.Boost.objects.count(), 0)
|
||||
|
||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.activitystreams.handle_boost_task.delay")
|
||||
@patch("bookwyrm.activitystreams.remove_status_task.delay")
|
||||
def test_unboost(self, *_):
|
||||
"""undo a boost"""
|
||||
boost = models.Boost.objects.create(
|
||||
|
@ -56,7 +56,7 @@ class InboxBlock(TestCase):
|
||||
}
|
||||
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_user_statuses"
|
||||
"bookwyrm.activitystreams.remove_user_statuses_task.delay"
|
||||
) as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
@ -94,7 +94,7 @@ class InboxBlock(TestCase):
|
||||
},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.add_user_statuses"
|
||||
"bookwyrm.activitystreams.add_user_statuses_task.delay"
|
||||
) as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
@ -1,4 +1,4 @@
|
||||
""" tests incoming activities"""
|
||||
"""tests incoming activities"""
|
||||
from datetime import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
@ -63,9 +63,7 @@ class InboxActivities(TestCase):
|
||||
"actor": self.remote_user.remote_id,
|
||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
with patch("bookwyrm.activitystreams.remove_status_task.delay") as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
# deletion doens't remove the status, it turns it into a tombstone
|
||||
@ -94,9 +92,7 @@ class InboxActivities(TestCase):
|
||||
"actor": self.remote_user.remote_id,
|
||||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
with patch("bookwyrm.activitystreams.remove_status_task.delay") as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
# deletion doens't remove the status, it turns it into a tombstone
|
||||
|
@ -183,7 +183,8 @@ class InboxRelationships(TestCase):
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertIsNone(self.local_user.followers.first())
|
||||
|
||||
def test_follow_accept(self):
|
||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
def test_follow_accept(self, _):
|
||||
"""a remote user approved a follow request from local"""
|
||||
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||
rel = models.UserFollowRequest.objects.create(
|
||||
|
@ -83,7 +83,8 @@ class InboxUpdate(TestCase):
|
||||
self.assertEqual(book_list.remote_id, "https://example.com/list/22")
|
||||
|
||||
@patch("bookwyrm.suggested_users.rerank_user_task.delay")
|
||||
def test_update_user(self, _):
|
||||
@patch("bookwyrm.activitystreams.add_user_statuses_task.delay")
|
||||
def test_update_user(self, *_):
|
||||
"""update an existing user"""
|
||||
models.UserFollows.objects.create(
|
||||
user_subject=self.local_user,
|
||||
|
Reference in New Issue
Block a user