forked from mirrors/bookwyrm
Updates updates tests
This commit is contained in:
parent
9e9fd5c5a6
commit
5caac46c31
1 changed files with 20 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
""" test for app action functionality """
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.http import JsonResponse
|
||||
from django.test import TestCase
|
||||
from django.test.client import RequestFactory
|
||||
|
@ -22,21 +24,33 @@ class UpdateViews(TestCase):
|
|||
)
|
||||
models.SiteSettings.objects.create()
|
||||
|
||||
def test_get_updates(self):
|
||||
def test_get_notification_count(self):
|
||||
""" there are so many views, this just makes sure it LOADS """
|
||||
view = views.Updates.as_view()
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
result = view(request)
|
||||
result = views.get_notification_count(request)
|
||||
self.assertIsInstance(result, JsonResponse)
|
||||
data = json.loads(result.getvalue())
|
||||
self.assertEqual(data["notifications"], 0)
|
||||
self.assertEqual(data["count"], 0)
|
||||
|
||||
models.Notification.objects.create(
|
||||
notification_type="BOOST", user=self.local_user
|
||||
)
|
||||
result = view(request)
|
||||
result = views.get_notification_count(request)
|
||||
self.assertIsInstance(result, JsonResponse)
|
||||
data = json.loads(result.getvalue())
|
||||
self.assertEqual(data["notifications"], 1)
|
||||
self.assertEqual(data["count"], 1)
|
||||
|
||||
def test_get_unread_status_count(self):
|
||||
""" there are so many views, this just makes sure it LOADS """
|
||||
request = self.factory.get("")
|
||||
request.user = self.local_user
|
||||
|
||||
with patch('bookwyrm.activitystreams.ActivityStream.get_unread_count') as mock:
|
||||
mock.return_value = 3
|
||||
result = views.get_unread_status_count(request, 'home')
|
||||
|
||||
self.assertIsInstance(result, JsonResponse)
|
||||
data = json.loads(result.getvalue())
|
||||
self.assertEqual(data["count"], 3)
|
||||
|
|
Loading…
Reference in a new issue