From 8bdedc93044a18dc11365441a45db1786969c1cb Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 16 Oct 2021 12:03:42 -0700 Subject: [PATCH] Catches some stray unvalidated html in landing tests --- bookwyrm/tests/views/landing/test_login.py | 5 +++-- bookwyrm/tests/views/landing/test_password.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bookwyrm/tests/views/landing/test_login.py b/bookwyrm/tests/views/landing/test_login.py index b4261326a..0f86fb791 100644 --- a/bookwyrm/tests/views/landing/test_login.py +++ b/bookwyrm/tests/views/landing/test_login.py @@ -7,6 +7,7 @@ from django.test import TestCase from django.test.client import RequestFactory from bookwyrm import forms, models, views +from bookwyrm.tests.validate_html import validate_html # pylint: disable=too-many-public-methods @@ -41,7 +42,7 @@ class LoginViews(TestCase): result = login(request) self.assertIsInstance(result, TemplateResponse) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) request.user = self.local_user @@ -102,7 +103,7 @@ class LoginViews(TestCase): with patch("bookwyrm.views.landing.login.login"): result = view(request) - result.render() + validate_html(result.render()) self.assertEqual(result.status_code, 200) self.assertEqual( result.context_data["login_form"].non_field_errors, diff --git a/bookwyrm/tests/views/landing/test_password.py b/bookwyrm/tests/views/landing/test_password.py index 3ab8b1214..f01565ef7 100644 --- a/bookwyrm/tests/views/landing/test_password.py +++ b/bookwyrm/tests/views/landing/test_password.py @@ -51,13 +51,13 @@ class PasswordViews(TestCase): view = views.PasswordResetRequest.as_view() resp = view(request) self.assertEqual(resp.status_code, 200) - resp.render() + validate_html(resp.render()) request = self.factory.post("", {"email": "mouse@mouse.com"}) request.user = self.anonymous_user with patch("bookwyrm.emailing.send_email.delay"): resp = view(request) - resp.render() + validate_html(resp.render()) self.assertEqual(models.PasswordReset.objects.get().user, self.local_user) @@ -116,7 +116,7 @@ class PasswordViews(TestCase): models.PasswordReset.objects.create(user=self.local_user) request = self.factory.post("", {"password": "hi", "confirm-password": "hi"}) resp = view(request, "jhgdkfjgdf") - resp.render() + validate_html(resp.render()) self.assertTrue(models.PasswordReset.objects.exists()) def test_password_reset_mismatch(self): @@ -125,5 +125,5 @@ class PasswordViews(TestCase): code = models.PasswordReset.objects.create(user=self.local_user) request = self.factory.post("", {"password": "hi", "confirm-password": "hihi"}) resp = view(request, code.code) - resp.render() + validate_html(resp.render()) self.assertTrue(models.PasswordReset.objects.exists())