forked from mirrors/bookwyrm
Updates activitystreams tests
This commit is contained in:
parent
e35c805960
commit
4ea9637a2d
6 changed files with 13 additions and 18 deletions
|
@ -464,7 +464,7 @@ def add_user_statuses_task(viewer_id, user_id, stream_list=None):
|
||||||
def handle_boost_task(boost_id):
|
def handle_boost_task(boost_id):
|
||||||
"""remove the original post and other, earlier boosts"""
|
"""remove the original post and other, earlier boosts"""
|
||||||
instance = models.Status.objects.get(id=boost_id)
|
instance = models.Status.objects.get(id=boost_id)
|
||||||
boosted = instance.boost.boosted_status.id
|
boosted = instance.boost.boosted_status
|
||||||
|
|
||||||
old_versions = models.Boost.objects.filter(
|
old_versions = models.Boost.objects.filter(
|
||||||
boosted_status__id=boosted.id,
|
boosted_status__id=boosted.id,
|
||||||
|
|
|
@ -6,7 +6,7 @@ from bookwyrm import activitystreams, models
|
||||||
|
|
||||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.BooksStream.add_book_statuses")
|
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
|
||||||
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
|
||||||
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
|
||||||
# pylint: disable=too-many-public-methods
|
# pylint: disable=too-many-public-methods
|
||||||
|
@ -296,9 +296,7 @@ class Activitystreams(TestCase):
|
||||||
def test_boost_to_another_timeline(self, *_):
|
def test_boost_to_another_timeline(self, *_):
|
||||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||||
with patch(
|
with patch("bookwyrm.activitystreams.handle_boost_task.delay"):
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
|
||||||
):
|
|
||||||
boost = models.Boost.objects.create(
|
boost = models.Boost.objects.create(
|
||||||
boosted_status=status,
|
boosted_status=status,
|
||||||
user=self.another_user,
|
user=self.another_user,
|
||||||
|
@ -306,7 +304,8 @@ class Activitystreams(TestCase):
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
||||||
) as mock:
|
) as mock:
|
||||||
activitystreams.add_status_on_create(models.Boost, boost, True)
|
activitystreams.handle_boost_task(boost.id)
|
||||||
|
|
||||||
self.assertTrue(mock.called)
|
self.assertTrue(mock.called)
|
||||||
call_args = mock.call_args
|
call_args = mock.call_args
|
||||||
self.assertEqual(call_args[0][0], status)
|
self.assertEqual(call_args[0][0], status)
|
||||||
|
@ -320,9 +319,7 @@ class Activitystreams(TestCase):
|
||||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||||
self.local_user.following.add(self.another_user)
|
self.local_user.following.add(self.another_user)
|
||||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||||
with patch(
|
with patch("bookwyrm.activitystreams.handle_boost_task.delay"):
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
|
||||||
):
|
|
||||||
boost = models.Boost.objects.create(
|
boost = models.Boost.objects.create(
|
||||||
boosted_status=status,
|
boosted_status=status,
|
||||||
user=self.another_user,
|
user=self.another_user,
|
||||||
|
@ -330,7 +327,7 @@ class Activitystreams(TestCase):
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
||||||
) as mock:
|
) as mock:
|
||||||
activitystreams.add_status_on_create(models.Boost, boost, True)
|
activitystreams.handle_boost_task(boost.id)
|
||||||
self.assertTrue(mock.called)
|
self.assertTrue(mock.called)
|
||||||
call_args = mock.call_args
|
call_args = mock.call_args
|
||||||
self.assertEqual(call_args[0][0], status)
|
self.assertEqual(call_args[0][0], status)
|
||||||
|
@ -346,9 +343,7 @@ class Activitystreams(TestCase):
|
||||||
def test_boost_to_same_timeline(self, *_):
|
def test_boost_to_same_timeline(self, *_):
|
||||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||||
with patch(
|
with patch("bookwyrm.activitystreams.handle_boost_task.delay"):
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
|
||||||
):
|
|
||||||
boost = models.Boost.objects.create(
|
boost = models.Boost.objects.create(
|
||||||
boosted_status=status,
|
boosted_status=status,
|
||||||
user=self.local_user,
|
user=self.local_user,
|
||||||
|
@ -356,7 +351,7 @@ class Activitystreams(TestCase):
|
||||||
with patch(
|
with patch(
|
||||||
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
"bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores"
|
||||||
) as mock:
|
) as mock:
|
||||||
activitystreams.add_status_on_create(models.Boost, boost, True)
|
activitystreams.handle_boost_task(boost.id)
|
||||||
self.assertTrue(mock.called)
|
self.assertTrue(mock.called)
|
||||||
call_args = mock.call_args
|
call_args = mock.call_args
|
||||||
self.assertEqual(call_args[0][0], status)
|
self.assertEqual(call_args[0][0], status)
|
||||||
|
|
Loading…
Reference in a new issue