diff --git a/bookwyrm/activitystreams.py b/bookwyrm/activitystreams.py index 4389fab41..6dedd7176 100644 --- a/bookwyrm/activitystreams.py +++ b/bookwyrm/activitystreams.py @@ -464,7 +464,7 @@ def add_user_statuses_task(viewer_id, user_id, stream_list=None): def handle_boost_task(boost_id): """remove the original post and other, earlier boosts""" 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( boosted_status__id=boosted.id, diff --git a/bookwyrm/tests/test_activitystreams.py b/bookwyrm/tests/test_activitystreams.py index aecc448c4..add5875f7 100644 --- a/bookwyrm/tests/test_activitystreams.py +++ b/bookwyrm/tests/test_activitystreams.py @@ -6,7 +6,7 @@ from bookwyrm import activitystreams, models @patch("bookwyrm.models.activitypub_mixin.broadcast_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.activitystreams.populate_stream_task.delay") # pylint: disable=too-many-public-methods @@ -296,9 +296,7 @@ class Activitystreams(TestCase): def test_boost_to_another_timeline(self, *_): """add a boost and deduplicate the boosted status on the timeline""" status = models.Status.objects.create(user=self.local_user, content="hi") - with patch( - "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" - ): + with patch("bookwyrm.activitystreams.handle_boost_task.delay"): boost = models.Boost.objects.create( boosted_status=status, user=self.another_user, @@ -306,7 +304,8 @@ class Activitystreams(TestCase): with patch( "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" ) as mock: - activitystreams.add_status_on_create(models.Boost, boost, True) + activitystreams.handle_boost_task(boost.id) + self.assertTrue(mock.called) call_args = mock.call_args 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""" self.local_user.following.add(self.another_user) status = models.Status.objects.create(user=self.local_user, content="hi") - with patch( - "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" - ): + with patch("bookwyrm.activitystreams.handle_boost_task.delay"): boost = models.Boost.objects.create( boosted_status=status, user=self.another_user, @@ -330,7 +327,7 @@ class Activitystreams(TestCase): with patch( "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" ) as mock: - activitystreams.add_status_on_create(models.Boost, boost, True) + activitystreams.handle_boost_task(boost.id) self.assertTrue(mock.called) call_args = mock.call_args self.assertEqual(call_args[0][0], status) @@ -346,9 +343,7 @@ class Activitystreams(TestCase): def test_boost_to_same_timeline(self, *_): """add a boost and deduplicate the boosted status on the timeline""" status = models.Status.objects.create(user=self.local_user, content="hi") - with patch( - "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" - ): + with patch("bookwyrm.activitystreams.handle_boost_task.delay"): boost = models.Boost.objects.create( boosted_status=status, user=self.local_user, @@ -356,7 +351,7 @@ class Activitystreams(TestCase): with patch( "bookwyrm.activitystreams.HomeStream.remove_object_from_related_stores" ) as mock: - activitystreams.add_status_on_create(models.Boost, boost, True) + activitystreams.handle_boost_task(boost.id) self.assertTrue(mock.called) call_args = mock.call_args self.assertEqual(call_args[0][0], status) diff --git a/bookwyrm/tests/views/test_directory.py b/bookwyrm/tests/views/test_directory.py index 52f9c0851..90638b0a6 100644 --- a/bookwyrm/tests/views/test_directory.py +++ b/bookwyrm/tests/views/test_directory.py @@ -32,7 +32,7 @@ class DirectoryViews(TestCase): self.anonymous_user.is_authenticated = False @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") -@patch("bookwyrm.activitystreams.populate_stream_task.delay") + @patch("bookwyrm.activitystreams.populate_stream_task.delay") @patch("bookwyrm.suggested_users.rerank_user_task.delay") def test_directory_page(self, *_): """there are so many views, this just makes sure it LOADS""" diff --git a/bookwyrm/tests/views/test_editions.py b/bookwyrm/tests/views/test_editions.py index 1cd256b1d..d1eb34c4a 100644 --- a/bookwyrm/tests/views/test_editions.py +++ b/bookwyrm/tests/views/test_editions.py @@ -103,7 +103,7 @@ class BookViews(TestCase): self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") -@patch("bookwyrm.activitystreams.populate_stream_task.delay") + @patch("bookwyrm.activitystreams.populate_stream_task.delay") def test_switch_edition(self, _): """updates user's relationships to a book""" work = models.Work.objects.create(title="test work") diff --git a/bookwyrm/tests/views/test_reports.py b/bookwyrm/tests/views/test_reports.py index 2f9ee27b8..1b0b6008a 100644 --- a/bookwyrm/tests/views/test_reports.py +++ b/bookwyrm/tests/views/test_reports.py @@ -119,7 +119,7 @@ class ReportViews(TestCase): self.assertFalse(report.resolved) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") -@patch("bookwyrm.activitystreams.populate_stream_task.delay") + @patch("bookwyrm.activitystreams.populate_stream_task.delay") @patch("bookwyrm.suggested_users.remove_user_task.delay") def test_suspend_user(self, *_): """toggle whether a user is able to log in""" diff --git a/bookwyrm/tests/views/test_user_admin.py b/bookwyrm/tests/views/test_user_admin.py index eab8ab686..3917a6fd9 100644 --- a/bookwyrm/tests/views/test_user_admin.py +++ b/bookwyrm/tests/views/test_user_admin.py @@ -51,7 +51,7 @@ class UserAdminViews(TestCase): self.assertEqual(result.status_code, 200) @patch("bookwyrm.suggested_users.rerank_suggestions_task.delay") -@patch("bookwyrm.activitystreams.populate_stream_task.delay") + @patch("bookwyrm.activitystreams.populate_stream_task.delay") @patch("bookwyrm.suggested_users.remove_user_task.delay") def test_user_admin_page_post(self, *_): """set the user's group"""