mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 20:11:14 +00:00
adds mocks to templatetags tests
This commit is contained in:
parent
2fcfebd4e5
commit
80241e59a7
1 changed files with 55 additions and 45 deletions
|
@ -35,6 +35,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_user_rating(self):
|
||||
''' get a user's most recent rating of a book '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.Review.objects.create(
|
||||
user=self.user, book=self.book, rating=3)
|
||||
self.assertEqual(
|
||||
|
@ -76,14 +77,16 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_replies(self):
|
||||
''' direct replies to a status '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
parent = models.Review.objects.create(
|
||||
user=self.user, book=self.book)
|
||||
user=self.user, book=self.book, content='hi')
|
||||
first_child = models.Status.objects.create(
|
||||
reply_parent=parent, user=self.user)
|
||||
reply_parent=parent, user=self.user, content='hi')
|
||||
second_child = models.Status.objects.create(
|
||||
reply_parent=parent, user=self.user)
|
||||
reply_parent=parent, user=self.user, content='hi')
|
||||
third_child = models.Status.objects.create(
|
||||
reply_parent=parent, user=self.user, deleted=True)
|
||||
reply_parent=parent, user=self.user,
|
||||
deleted=True, deleted_date=timezone.now())
|
||||
|
||||
replies = bookwyrm_tags.get_replies(parent)
|
||||
self.assertEqual(len(replies), 2)
|
||||
|
@ -94,10 +97,11 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_parent(self):
|
||||
''' get the reply parent of a status '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
parent = models.Review.objects.create(
|
||||
user=self.user, book=self.book)
|
||||
user=self.user, book=self.book, content='hi')
|
||||
child = models.Status.objects.create(
|
||||
reply_parent=parent, user=self.user)
|
||||
reply_parent=parent, user=self.user, content='hi')
|
||||
|
||||
result = bookwyrm_tags.get_parent(child)
|
||||
self.assertEqual(result, parent)
|
||||
|
@ -110,6 +114,7 @@ class TemplateTags(TestCase):
|
|||
user=self.remote_user, book=self.book)
|
||||
|
||||
self.assertFalse(bookwyrm_tags.get_user_liked(self.user, status))
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.Favorite.objects.create(
|
||||
user=self.user,
|
||||
status=status
|
||||
|
@ -123,6 +128,7 @@ class TemplateTags(TestCase):
|
|||
user=self.remote_user, book=self.book)
|
||||
|
||||
self.assertFalse(bookwyrm_tags.get_user_boosted(self.user, status))
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.Boost.objects.create(
|
||||
user=self.user,
|
||||
boosted_status=status
|
||||
|
@ -135,6 +141,7 @@ class TemplateTags(TestCase):
|
|||
self.assertFalse(
|
||||
bookwyrm_tags.follow_request_exists(self.user, self.remote_user))
|
||||
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
models.UserFollowRequest.objects.create(
|
||||
user_subject=self.user,
|
||||
user_object=self.remote_user)
|
||||
|
@ -147,6 +154,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_boosted(self):
|
||||
''' load a boosted status '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
status = models.Review.objects.create(
|
||||
user=self.remote_user, book=self.book)
|
||||
boost = models.Boost.objects.create(
|
||||
|
@ -233,6 +241,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_get_status_preview_name(self):
|
||||
''' status context string '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
status = models.Status.objects.create(content='hi', user=self.user)
|
||||
result = bookwyrm_tags.get_status_preview_name(status)
|
||||
self.assertEqual(result, 'status')
|
||||
|
@ -255,6 +264,7 @@ class TemplateTags(TestCase):
|
|||
|
||||
def test_related_status(self):
|
||||
''' gets the subclass model for a notification status '''
|
||||
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||
status = models.Status.objects.create(content='hi', user=self.user)
|
||||
notification = models.Notification.objects.create(
|
||||
user=self.user, notification_type='MENTION',
|
||||
|
|
Loading…
Reference in a new issue