Activitystreams mocks

This commit is contained in:
Mouse Reeve 2021-12-09 20:38:44 -08:00
parent 0c193b6ce1
commit 59e6b67bc8

View file

@ -5,6 +5,8 @@ from bookwyrm import activitystreams, models
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async")
@patch("bookwyrm.lists_stream.add_user_lists_task.delay")
@patch("bookwyrm.lists_stream.remove_user_lists_task.delay")
class ActivitystreamsSignals(TestCase):
"""using redis to build activity streams"""
@ -32,11 +34,11 @@ class ActivitystreamsSignals(TestCase):
work = models.Work.objects.create(title="test work")
self.book = models.Edition.objects.create(title="test book", parent_work=work)
def test_add_status_on_create_ignore(self, _):
def test_add_status_on_create_ignore(self, *_):
"""a new statuses has entered"""
activitystreams.add_status_on_create(models.User, self.local_user, False)
def test_add_status_on_create_deleted(self, _):
def test_add_status_on_create_deleted(self, *_):
"""a new statuses has entered"""
with patch("bookwyrm.activitystreams.remove_status_task.delay"):
status = models.Status.objects.create(
@ -48,7 +50,7 @@ class ActivitystreamsSignals(TestCase):
args = mock.call_args[0]
self.assertEqual(args[0], status.id)
def test_add_status_on_create_created(self, _):
def test_add_status_on_create_created(self, *_):
"""a new statuses has entered"""
status = models.Status.objects.create(
user=self.remote_user, content="hi", privacy="public"
@ -60,7 +62,7 @@ class ActivitystreamsSignals(TestCase):
self.assertEqual(args["args"][0], status.id)
self.assertEqual(args["queue"], "high_priority")
def test_populate_streams_on_account_create(self, _):
def test_populate_streams_on_account_create(self, *_):
"""create streams for a user"""
with patch("bookwyrm.activitystreams.populate_stream_task.delay") as mock:
activitystreams.populate_streams_on_account_create(
@ -71,7 +73,7 @@ class ActivitystreamsSignals(TestCase):
self.assertEqual(args[0], "books")
self.assertEqual(args[1], self.local_user.id)
def test_remove_statuses_on_block(self, _):
def test_remove_statuses_on_block(self, *_):
"""don't show statuses from blocked users"""
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay") as mock:
models.UserBlocks.objects.create(
@ -83,7 +85,7 @@ class ActivitystreamsSignals(TestCase):
self.assertEqual(args[0], self.local_user.id)
self.assertEqual(args[1], self.remote_user.id)
def test_add_statuses_on_unblock(self, _):
def test_add_statuses_on_unblock(self, *_):
"""re-add statuses on unblock"""
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"):
block = models.UserBlocks.objects.create(
@ -100,7 +102,7 @@ class ActivitystreamsSignals(TestCase):
self.assertEqual(args[1], self.remote_user.id)
self.assertEqual(kwargs["stream_list"], ["local", "books"])
def test_add_statuses_on_unblock_reciprocal_block(self, _):
def test_add_statuses_on_unblock_reciprocal_block(self, *_):
"""re-add statuses on unblock"""
with patch("bookwyrm.activitystreams.remove_user_statuses_task.delay"):
block = models.UserBlocks.objects.create(