Skip to content

Commit

Permalink
Add test for invalid profile edit attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
John Solly committed Jul 20, 2023
1 parent 430718c commit 9ce0537
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions django_project/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,19 @@ def test_profile_view_edit(self):
self.assertEqual(self.comment_only_user.email, "[email protected]")
self.assertEqual(self.comment_only_user.username, "modified")

def test_profile_view_edit_invalid(self):
self.client.login(
username=self.comment_only_user.username, password=self.test_password
)
response = self.client.post(
reverse("profile"),
data={"email": "invalid", "username": ""},
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "users/profile.html")
self.assertIsInstance(response.context["p_form"], ProfileUpdateForm)
self.assertIsInstance(response.context["u_form"], UserUpdateForm)

def test_login_view(self):
response = self.client.get(reverse("login"))
self.assertEqual(response.status_code, 200)
Expand Down

0 comments on commit 9ce0537

Please sign in to comment.