Use validate html in landing views tests

This commit is contained in:
Mouse Reeve 2021-10-16 10:09:25 -07:00
parent 8cb91acb93
commit b56147d70c
3 changed files with 15 additions and 12 deletions

View file

@ -8,6 +8,7 @@ from django.test.client import RequestFactory
from bookwyrm import forms, models from bookwyrm import forms, models
from bookwyrm import views from bookwyrm import views
from bookwyrm.tests.validate_html import validate_html
class InviteViews(TestCase): class InviteViews(TestCase):
@ -40,7 +41,7 @@ class InviteViews(TestCase):
invite.return_value = True invite.return_value = True
result = view(request, "hi") result = view(request, "hi")
self.assertIsInstance(result, TemplateResponse) self.assertIsInstance(result, TemplateResponse)
result.render() validate_html(result.render())
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
def test_manage_invites(self): def test_manage_invites(self):
@ -51,7 +52,7 @@ class InviteViews(TestCase):
request.user.is_superuser = True request.user.is_superuser = True
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) self.assertEqual(result.status_code, 200)
def test_manage_invites_post(self): def test_manage_invites_post(self):
@ -67,7 +68,7 @@ class InviteViews(TestCase):
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) self.assertEqual(result.status_code, 200)
invite = models.SiteInvite.objects.get() invite = models.SiteInvite.objects.get()
@ -83,7 +84,7 @@ class InviteViews(TestCase):
request = self.factory.post("", form.data) request = self.factory.post("", form.data)
result = view(request) result = view(request)
result.render() validate_html(result.render())
req = models.InviteRequest.objects.get() req = models.InviteRequest.objects.get()
self.assertEqual(req.email, "new@user.email") self.assertEqual(req.email, "new@user.email")
@ -97,7 +98,7 @@ class InviteViews(TestCase):
request = self.factory.post("", form.data) request = self.factory.post("", form.data)
result = view(request) result = view(request)
result.render() validate_html(result.render())
# no request created # no request created
self.assertFalse(models.InviteRequest.objects.exists()) self.assertFalse(models.InviteRequest.objects.exists())
@ -110,14 +111,14 @@ class InviteViews(TestCase):
request.user.is_superuser = True request.user.is_superuser = True
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) self.assertEqual(result.status_code, 200)
# now with data # now with data
models.InviteRequest.objects.create(email="fish@example.com") models.InviteRequest.objects.create(email="fish@example.com")
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) self.assertEqual(result.status_code, 200)
def test_manage_invite_requests_send(self): def test_manage_invite_requests_send(self):

View file

@ -7,6 +7,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 LandingViews(TestCase): class LandingViews(TestCase):
@ -38,13 +39,13 @@ class LandingViews(TestCase):
with patch("bookwyrm.activitystreams.ActivityStream.get_activity_stream"): with patch("bookwyrm.activitystreams.ActivityStream.get_activity_stream"):
result = view(request) result = view(request)
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
result.render() validate_html(result.render())
request.user = self.anonymous_user request.user = self.anonymous_user
result = view(request) result = view(request)
self.assertIsInstance(result, TemplateResponse) self.assertIsInstance(result, TemplateResponse)
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
result.render() validate_html(result.render())
def test_about_page(self): def test_about_page(self):
"""there are so many views, this just makes sure it LOADS""" """there are so many views, this just makes sure it LOADS"""
@ -53,7 +54,7 @@ class LandingViews(TestCase):
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) self.assertEqual(result.status_code, 200)
def test_landing(self): def test_landing(self):

View file

@ -7,6 +7,7 @@ from django.test import TestCase
from django.test.client import RequestFactory from django.test.client import RequestFactory
from bookwyrm import models, views from bookwyrm import models, views
from bookwyrm.tests.validate_html import validate_html
class PasswordViews(TestCase): class PasswordViews(TestCase):
@ -37,7 +38,7 @@ class PasswordViews(TestCase):
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) self.assertEqual(result.status_code, 200)
def test_password_reset_request_post(self): def test_password_reset_request_post(self):
@ -65,7 +66,7 @@ class PasswordViews(TestCase):
request.user = self.anonymous_user request.user = self.anonymous_user
result = view(request, code.code) result = view(request, code.code)
self.assertIsInstance(result, TemplateResponse) self.assertIsInstance(result, TemplateResponse)
result.render() validate_html(result.render())
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
def test_password_reset_post(self): def test_password_reset_post(self):