mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +00:00
Expands notifications views test
This commit is contained in:
parent
1d79bb58e1
commit
0320898f4e
1 changed files with 40 additions and 2 deletions
|
@ -6,6 +6,7 @@ from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from bookwyrm import views
|
from bookwyrm import views
|
||||||
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
class NotificationViews(TestCase):
|
class NotificationViews(TestCase):
|
||||||
|
@ -24,16 +25,53 @@ class NotificationViews(TestCase):
|
||||||
local=True,
|
local=True,
|
||||||
localname="mouse",
|
localname="mouse",
|
||||||
)
|
)
|
||||||
|
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.delay"):
|
||||||
|
self.status = models.Status.objects.create(
|
||||||
|
content="hi",
|
||||||
|
user=self.local_user,
|
||||||
|
)
|
||||||
models.SiteSettings.objects.create()
|
models.SiteSettings.objects.create()
|
||||||
|
|
||||||
def test_notifications_page(self):
|
def test_notifications_page_empty(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Notifications.as_view()
|
view = views.Notifications.as_view()
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
result = view(request)
|
result = view(request)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
result.render()
|
validate_html(result.render())
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
|
def test_notifications_page_notifications(self):
|
||||||
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
|
models.Notification.objects.create(
|
||||||
|
user=self.local_user,
|
||||||
|
notification_type="FAVORITE",
|
||||||
|
related_status=self.status,
|
||||||
|
)
|
||||||
|
models.Notification.objects.create(
|
||||||
|
user=self.local_user,
|
||||||
|
notification_type="BOOST",
|
||||||
|
related_status=self.status,
|
||||||
|
)
|
||||||
|
models.Notification.objects.create(
|
||||||
|
user=self.local_user,
|
||||||
|
notification_type="MENTION",
|
||||||
|
related_status=self.status,
|
||||||
|
)
|
||||||
|
self.status.reply_parent = self.status
|
||||||
|
self.status.save(broadcast=False)
|
||||||
|
models.Notification.objects.create(
|
||||||
|
user=self.local_user,
|
||||||
|
notification_type="REPLY",
|
||||||
|
related_status=self.status,
|
||||||
|
)
|
||||||
|
view = views.Notifications.as_view()
|
||||||
|
request = self.factory.get("")
|
||||||
|
request.user = self.local_user
|
||||||
|
result = view(request)
|
||||||
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
|
validate_html(result.render())
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
def test_clear_notifications(self):
|
def test_clear_notifications(self):
|
||||||
|
|
Loading…
Reference in a new issue