Skip to content

Commit

Permalink
tests(mfa): assertFormError vs __all__
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Nov 27, 2023
1 parent b49d3b1 commit fa223c6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions allauth/mfa/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,12 @@ def test_cannot_deactivate_totp(auth_client, user_with_totp, user_password):
assert resp.status_code == 302
resp = auth_client.get(reverse("mfa_deactivate_totp"))
# When we GET, the form validation error is already on screen
assertFormError(
resp,
"form",
"__all__",
get_adapter().error_messages["cannot_delete_authenticator"],
)
assert resp.context["form"].errors == {
"__all__": [get_adapter().error_messages["cannot_delete_authenticator"]],
}
# And, when we POST anyway, it does not work
resp = auth_client.post(reverse("mfa_deactivate_totp"))
assert resp.status_code == 200
assertFormError(
resp,
"form",
"__all__",
get_adapter().error_messages["cannot_delete_authenticator"],
)
assert resp.context["form"].errors == {
"__all__": [get_adapter().error_messages["cannot_delete_authenticator"]],
}

0 comments on commit fa223c6

Please sign in to comment.