adds mocks to templatetags tests
This commit is contained in:
parent
2fcfebd4e5
commit
80241e59a7
|
@ -35,6 +35,7 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_user_rating(self):
|
def test_get_user_rating(self):
|
||||||
''' get a user's most recent rating of a book '''
|
''' get a user's most recent rating of a book '''
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
models.Review.objects.create(
|
models.Review.objects.create(
|
||||||
user=self.user, book=self.book, rating=3)
|
user=self.user, book=self.book, rating=3)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -76,14 +77,16 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_replies(self):
|
def test_get_replies(self):
|
||||||
''' direct replies to a status '''
|
''' direct replies to a status '''
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
parent = models.Review.objects.create(
|
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(
|
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(
|
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(
|
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)
|
replies = bookwyrm_tags.get_replies(parent)
|
||||||
self.assertEqual(len(replies), 2)
|
self.assertEqual(len(replies), 2)
|
||||||
|
@ -94,10 +97,11 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_parent(self):
|
def test_get_parent(self):
|
||||||
''' get the reply parent of a status '''
|
''' get the reply parent of a status '''
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
parent = models.Review.objects.create(
|
parent = models.Review.objects.create(
|
||||||
user=self.user, book=self.book)
|
user=self.user, book=self.book, content='hi')
|
||||||
child = models.Status.objects.create(
|
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)
|
result = bookwyrm_tags.get_parent(child)
|
||||||
self.assertEqual(result, parent)
|
self.assertEqual(result, parent)
|
||||||
|
@ -110,6 +114,7 @@ class TemplateTags(TestCase):
|
||||||
user=self.remote_user, book=self.book)
|
user=self.remote_user, book=self.book)
|
||||||
|
|
||||||
self.assertFalse(bookwyrm_tags.get_user_liked(self.user, status))
|
self.assertFalse(bookwyrm_tags.get_user_liked(self.user, status))
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
models.Favorite.objects.create(
|
models.Favorite.objects.create(
|
||||||
user=self.user,
|
user=self.user,
|
||||||
status=status
|
status=status
|
||||||
|
@ -123,6 +128,7 @@ class TemplateTags(TestCase):
|
||||||
user=self.remote_user, book=self.book)
|
user=self.remote_user, book=self.book)
|
||||||
|
|
||||||
self.assertFalse(bookwyrm_tags.get_user_boosted(self.user, status))
|
self.assertFalse(bookwyrm_tags.get_user_boosted(self.user, status))
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
models.Boost.objects.create(
|
models.Boost.objects.create(
|
||||||
user=self.user,
|
user=self.user,
|
||||||
boosted_status=status
|
boosted_status=status
|
||||||
|
@ -135,6 +141,7 @@ class TemplateTags(TestCase):
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
bookwyrm_tags.follow_request_exists(self.user, self.remote_user))
|
bookwyrm_tags.follow_request_exists(self.user, self.remote_user))
|
||||||
|
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
models.UserFollowRequest.objects.create(
|
models.UserFollowRequest.objects.create(
|
||||||
user_subject=self.user,
|
user_subject=self.user,
|
||||||
user_object=self.remote_user)
|
user_object=self.remote_user)
|
||||||
|
@ -147,6 +154,7 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_boosted(self):
|
def test_get_boosted(self):
|
||||||
''' load a boosted status '''
|
''' load a boosted status '''
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
status = models.Review.objects.create(
|
status = models.Review.objects.create(
|
||||||
user=self.remote_user, book=self.book)
|
user=self.remote_user, book=self.book)
|
||||||
boost = models.Boost.objects.create(
|
boost = models.Boost.objects.create(
|
||||||
|
@ -233,6 +241,7 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_get_status_preview_name(self):
|
def test_get_status_preview_name(self):
|
||||||
''' status context string '''
|
''' status context string '''
|
||||||
|
with patch('bookwyrm.models.activitypub_mixin.broadcast_task.delay'):
|
||||||
status = models.Status.objects.create(content='hi', user=self.user)
|
status = models.Status.objects.create(content='hi', user=self.user)
|
||||||
result = bookwyrm_tags.get_status_preview_name(status)
|
result = bookwyrm_tags.get_status_preview_name(status)
|
||||||
self.assertEqual(result, 'status')
|
self.assertEqual(result, 'status')
|
||||||
|
@ -255,6 +264,7 @@ class TemplateTags(TestCase):
|
||||||
|
|
||||||
def test_related_status(self):
|
def test_related_status(self):
|
||||||
''' gets the subclass model for a notification status '''
|
''' 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)
|
status = models.Status.objects.create(content='hi', user=self.user)
|
||||||
notification = models.Notification.objects.create(
|
notification = models.Notification.objects.create(
|
||||||
user=self.user, notification_type='MENTION',
|
user=self.user, notification_type='MENTION',
|
||||||
|
|
Loading…
Reference in New Issue