Merge branch 'main' into opengraph-image-generation

This commit is contained in:
Mouse Reeve
2021-06-17 15:17:54 -07:00
committed by GitHub
86 changed files with 2188 additions and 1834 deletions

View File

@ -8,6 +8,7 @@ from bookwyrm import models, views
@patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay")
@patch("bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores")
class InteractionViews(TestCase):
"""viewing and creating statuses"""
@ -42,7 +43,7 @@ class InteractionViews(TestCase):
parent_work=work,
)
def test_favorite(self, _):
def test_favorite(self, *_):
"""create and broadcast faving a status"""
view = views.Favorite.as_view()
request = self.factory.post("")
@ -60,7 +61,7 @@ class InteractionViews(TestCase):
self.assertEqual(notification.user, self.local_user)
self.assertEqual(notification.related_user, self.remote_user)
def test_unfavorite(self, _):
def test_unfavorite(self, *_):
"""unfav a status"""
view = views.Unfavorite.as_view()
request = self.factory.post("")
@ -77,7 +78,7 @@ class InteractionViews(TestCase):
self.assertEqual(models.Favorite.objects.count(), 0)
self.assertEqual(models.Notification.objects.count(), 0)
def test_boost(self, _):
def test_boost(self, *_):
"""boost a status"""
view = views.Boost.as_view()
request = self.factory.post("")
@ -99,7 +100,7 @@ class InteractionViews(TestCase):
self.assertEqual(notification.related_user, self.remote_user)
self.assertEqual(notification.related_status, status)
def test_self_boost(self, _):
def test_self_boost(self, *_):
"""boost your own status"""
view = views.Boost.as_view()
request = self.factory.post("")
@ -123,7 +124,7 @@ class InteractionViews(TestCase):
self.assertFalse(models.Notification.objects.exists())
def test_boost_unlisted(self, _):
def test_boost_unlisted(self, *_):
"""boost a status"""
view = views.Boost.as_view()
request = self.factory.post("")
@ -138,7 +139,7 @@ class InteractionViews(TestCase):
boost = models.Boost.objects.get()
self.assertEqual(boost.privacy, "unlisted")
def test_boost_private(self, _):
def test_boost_private(self, *_):
"""boost a status"""
view = views.Boost.as_view()
request = self.factory.post("")
@ -151,7 +152,7 @@ class InteractionViews(TestCase):
view(request, status.id)
self.assertFalse(models.Boost.objects.exists())
def test_boost_twice(self, _):
def test_boost_twice(self, *_):
"""boost a status"""
view = views.Boost.as_view()
request = self.factory.post("")
@ -163,13 +164,17 @@ class InteractionViews(TestCase):
view(request, status.id)
self.assertEqual(models.Boost.objects.count(), 1)
def test_unboost(self, _):
@patch("bookwyrm.activitystreams.ActivityStream.add_status")
def test_unboost(self, *_):
"""undo a boost"""
view = views.Unboost.as_view()
request = self.factory.post("")
request.user = self.remote_user
with patch("bookwyrm.activitystreams.ActivityStream.add_status"):
status = models.Status.objects.create(user=self.local_user, content="hi")
status = models.Status.objects.create(user=self.local_user, content="hi")
with patch(
"bookwyrm.activitystreams.ActivityStream.remove_object_from_related_stores"
):
views.Boost.as_view()(request, status.id)
self.assertEqual(models.Boost.objects.count(), 1)