A few more mocks
This commit is contained in:
@ -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"""
|
||||
|
Reference in New Issue
Block a user