Render test for change password view

This commit is contained in:
Mouse Reeve 2021-09-28 11:09:24 -07:00
parent f281d9014a
commit e971638f14
2 changed files with 19 additions and 3 deletions

View file

@ -10,11 +10,11 @@
{% block panel %} {% block panel %}
<form name="edit-profile" action="{% url 'prefs-password' %}" method="post" enctype="multipart/form-data"> <form name="edit-profile" action="{% url 'prefs-password' %}" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<div class="block"> <div class="field">
<label class="label" for="id_password">{% trans "New password:" %}</label> <label class="label" for="id_password">{% trans "New password:" %}</label>
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password"> <input type="password" name="password" maxlength="128" class="input" required="" id="id_password">
</div> </div>
<div class="block"> <div class="field">
<label class="label" for="id_confirm_password">{% trans "Confirm password:" %}</label> <label class="label" for="id_confirm_password">{% trans "Confirm password:" %}</label>
<input type="password" name="confirm-password" maxlength="128" class="input" required="" id="id_confirm_password"> <input type="password" name="confirm-password" maxlength="128" class="input" required="" id="id_confirm_password">
</div> </div>

View file

@ -127,6 +127,19 @@ class EditUserViews(TestCase):
image_result = Image.open(result) image_result = Image.open(result)
self.assertEqual(image_result.size, (120, 120)) self.assertEqual(image_result.size, (120, 120))
def test_change_password_page(self, _):
"""there are so many views, this just makes sure it LOADS"""
view = views.ChangePassword.as_view()
request = self.factory.get("")
request.user = self.local_user
result = view(request)
self.assertIsInstance(result, TemplateResponse)
html = result.render()
_, errors = tidy_document(html.content)
if errors:
raise Exception(errors)
self.assertEqual(result.status_code, 200)
def test_delete_user_page(self, _): def test_delete_user_page(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.DeleteUser.as_view() view = views.DeleteUser.as_view()
@ -134,7 +147,10 @@ class EditUserViews(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() html = result.render()
_, errors = tidy_document(html.content)
if errors:
raise Exception(errors)
self.assertEqual(result.status_code, 200) self.assertEqual(result.status_code, 200)
@patch("bookwyrm.suggested_users.rerank_suggestions_task") @patch("bookwyrm.suggested_users.rerank_suggestions_task")