mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
Lightly updates tests
This commit is contained in:
parent
443750d6db
commit
321949f2fa
3 changed files with 5 additions and 2 deletions
|
@ -480,12 +480,14 @@ def handle_boost_task(boost_id):
|
|||
instance = models.Status.objects.get(id=boost_id)
|
||||
boosted = instance.boost.boosted_status
|
||||
|
||||
# previous boosts of this status
|
||||
old_versions = models.Boost.objects.filter(
|
||||
boosted_status__id=boosted.id,
|
||||
created_date__lt=instance.created_date,
|
||||
)
|
||||
|
||||
for stream in streams.values():
|
||||
# people who should see the boost (not people who see the original status)
|
||||
audience = stream.get_stores_for_object(instance)
|
||||
stream.remove_object_from_related_stores(boosted, stores=audience)
|
||||
for status in old_versions:
|
||||
|
|
|
@ -35,7 +35,7 @@ class RedisStore(ABC):
|
|||
|
||||
def remove_object_from_related_stores(self, obj, stores=None):
|
||||
"""remove an object from all stores"""
|
||||
stores = stores or self.get_stores_for_object(obj)
|
||||
stores = self.get_stores_for_object(obj) if stores is None else stores
|
||||
pipeline = r.pipeline()
|
||||
for store in stores:
|
||||
pipeline.zrem(store, -1, obj.id)
|
||||
|
|
|
@ -125,7 +125,7 @@ class Activitystreams(TestCase):
|
|||
@patch("bookwyrm.activitystreams.BooksStream.remove_object_from_related_stores")
|
||||
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
|
||||
def test_boost_to_another_timeline(self, *_):
|
||||
"""add a boost and deduplicate the boosted status on the timeline"""
|
||||
"""boost from a non-follower doesn't remove original status from feed"""
|
||||
status = models.Status.objects.create(user=self.local_user, content="hi")
|
||||
with patch("bookwyrm.activitystreams.handle_boost_task.delay"):
|
||||
boost = models.Boost.objects.create(
|
||||
|
@ -138,6 +138,7 @@ class Activitystreams(TestCase):
|
|||
activitystreams.handle_boost_task(boost.id)
|
||||
|
||||
self.assertTrue(mock.called)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
call_args = mock.call_args
|
||||
self.assertEqual(call_args[0][0], status)
|
||||
self.assertEqual(
|
||||
|
|
Loading…
Reference in a new issue