mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
Adds unit test for failing view
This commit is contained in:
parent
1a8580cdbc
commit
f95729a0c3
2 changed files with 15 additions and 1 deletions
|
@ -15,6 +15,7 @@ from bookwyrm.tests.validate_html import validate_html
|
|||
class ReportViews(TestCase):
|
||||
"""every response to a get request, html or json"""
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def setUp(self):
|
||||
"""we need basic test data and mocks"""
|
||||
self.factory = RequestFactory()
|
||||
|
@ -147,3 +148,16 @@ class ReportViews(TestCase):
|
|||
self.rat.refresh_from_db()
|
||||
self.assertFalse(self.rat.is_active)
|
||||
self.assertEqual(self.rat.deactivation_reason, "moderator_deletion")
|
||||
|
||||
def test_delete_user_error(self, *_):
|
||||
"""toggle whether a user is able to log in"""
|
||||
self.assertTrue(self.rat.is_active)
|
||||
request = self.factory.post("", {"password": "wrong password"})
|
||||
request.user = self.local_user
|
||||
|
||||
result = views.moderator_delete_user(request, self.rat.id)
|
||||
self.assertIsInstance(result, TemplateResponse)
|
||||
validate_html(result.render())
|
||||
|
||||
self.rat.refresh_from_db()
|
||||
self.assertTrue(self.rat.is_active)
|
||||
|
|
|
@ -128,7 +128,7 @@ def moderator_delete_user(request, user_id):
|
|||
form.errors["password"] = ["Invalid password"]
|
||||
|
||||
data = {"user": user, "group_form": forms.UserGroupForm(), "form": form}
|
||||
return TemplateResponse(request, "user_admin/user.html", data)
|
||||
return TemplateResponse(request, "settings/users/user.html", data)
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue