Merge branch 'main' into domain-block
This commit is contained in:
commit
4e0225749d
23 changed files with 331 additions and 144 deletions
|
@ -446,7 +446,7 @@ class Inbox(TestCase):
|
|||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
@ -479,7 +479,7 @@ class Inbox(TestCase):
|
|||
"object": {"id": self.status.remote_id, "type": "Tombstone"},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
@ -574,6 +574,56 @@ class Inbox(TestCase):
|
|||
self.assertEqual(notification.user, self.local_user)
|
||||
self.assertEqual(notification.related_status, self.status)
|
||||
|
||||
@responses.activate
|
||||
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
|
||||
def test_handle_boost_remote_status(self, redis_mock):
|
||||
""" boost a status """
|
||||
work = models.Work.objects.create(title="work title")
|
||||
book = models.Edition.objects.create(
|
||||
title="Test",
|
||||
remote_id="https://bookwyrm.social/book/37292",
|
||||
parent_work=work,
|
||||
)
|
||||
self.assertEqual(models.Notification.objects.count(), 0)
|
||||
activity = {
|
||||
"type": "Announce",
|
||||
"id": "%s/boost" % self.status.remote_id,
|
||||
"actor": self.remote_user.remote_id,
|
||||
"object": "https://remote.com/status/1",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||
"cc": ["https://example.com/user/mouse/followers"],
|
||||
"published": "Mon, 25 May 2020 19:31:20 GMT",
|
||||
}
|
||||
responses.add(
|
||||
responses.GET,
|
||||
"https://remote.com/status/1",
|
||||
json={
|
||||
"id": "https://remote.com/status/1",
|
||||
"type": "Comment",
|
||||
"published": "2021-04-05T18:04:59.735190+00:00",
|
||||
"attributedTo": self.remote_user.remote_id,
|
||||
"content": "<p>a comment</p>",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc": ["https://b875df3d118b.ngrok.io/user/mouse/followers"],
|
||||
"inReplyTo": "",
|
||||
"inReplyToBook": book.remote_id,
|
||||
"summary": "",
|
||||
"tag": [],
|
||||
"sensitive": False,
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
},
|
||||
)
|
||||
|
||||
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")
|
||||
self.assertEqual(boost.boosted_status.comment.status_type, "Comment")
|
||||
self.assertEqual(boost.boosted_status.comment.book, book)
|
||||
|
||||
@responses.activate
|
||||
def test_handle_discarded_boost(self):
|
||||
""" test a boost of a mastodon status that will be discarded """
|
||||
|
@ -618,7 +668,7 @@ class Inbox(TestCase):
|
|||
},
|
||||
}
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
views.inbox.activity_task(activity)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
|
|
@ -164,7 +164,7 @@ class InteractionViews(TestCase):
|
|||
self.assertEqual(models.Boost.objects.count(), 1)
|
||||
self.assertEqual(models.Notification.objects.count(), 1)
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
view(request, status.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
|
|
@ -177,7 +177,9 @@ class StatusViews(TestCase):
|
|||
content="hi", book=self.book, user=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.remove_status") as mock:
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as mock:
|
||||
result = view(request, status.id)
|
||||
self.assertTrue(mock.called)
|
||||
result.render()
|
||||
|
@ -196,7 +198,9 @@ class StatusViews(TestCase):
|
|||
book=self.book, rating=2.0, user=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.remove_status") as mock:
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as mock:
|
||||
result = view(request, status.id)
|
||||
self.assertFalse(mock.called)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
@ -214,7 +218,9 @@ class StatusViews(TestCase):
|
|||
content="hi", user=self.local_user
|
||||
)
|
||||
|
||||
with patch("bookwyrm.activitystreams.ActivityStream.remove_status") as mock:
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as mock:
|
||||
result = view(request, status.id)
|
||||
self.assertFalse(mock.called)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
@ -316,7 +322,7 @@ class StatusViews(TestCase):
|
|||
request.user = self.local_user
|
||||
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
view(request, status.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
@ -351,7 +357,7 @@ class StatusViews(TestCase):
|
|||
request.user.is_superuser = True
|
||||
|
||||
with patch(
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_status"
|
||||
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
|
||||
) as redis_mock:
|
||||
view(request, status.id)
|
||||
self.assertTrue(redis_mock.called)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue