A few more mocks

This commit is contained in:
Mouse Reeve
2021-11-12 10:49:49 -08:00
parent cad5a128ac
commit 309d289a65
2 changed files with 6 additions and 29 deletions

View File

@ -362,19 +362,15 @@ class Status(TestCase):
def test_favorite(self, *_):
"""fav a status"""
real_broadcast = models.Favorite.broadcast
def fav_broadcast_mock(_, activity, user):
"""ok"""
self.assertEqual(user.remote_id, self.local_user.remote_id)
self.assertEqual(activity["type"], "Like")
models.Favorite.broadcast = fav_broadcast_mock
status = models.Status.objects.create(
content="test content", user=self.local_user
)
fav = models.Favorite.objects.create(status=status, user=self.local_user)
with patch("bookwyrm.models.Favorite.broadcast") as mock:
fav = models.Favorite.objects.create(status=status, user=self.local_user)
args = mock.call_args[0]
self.assertEqual(args[1].remote_id, self.local_user.remote_id)
self.assertEqual(args[0]["type"], "Like")
# can't fav a status twice
with self.assertRaises(IntegrityError):
@ -384,7 +380,6 @@ class Status(TestCase):
self.assertEqual(activity["type"], "Like")
self.assertEqual(activity["actor"], self.local_user.remote_id)
self.assertEqual(activity["object"], status.remote_id)
models.Favorite.broadcast = real_broadcast
def test_boost(self, *_):
"""boosting, this one's a bit fussy"""