Skip to content

Commit

Permalink
tests: Python 3.8 with compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Sep 23, 2024
1 parent dcea7ff commit fc7627c
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions allauth/account/tests/test_email_verification_by_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,31 @@ def test_add_or_change_email(auth_client, user, get_last_code, change_email, set
settings.ACCOUNT_CHANGE_EMAIL = change_email
email = "additional@email.org"
assert EmailAddress.objects.filter(user=user).count() == 1
with (
patch("allauth.account.signals.email_added") as email_added_signal,
patch("allauth.account.signals.email_changed") as email_changed_signal,
):
resp = auth_client.post(
reverse("account_email"), {"action_add": "", "email": email}
)
assert resp["location"] == reverse("account_email_verification_sent")
assert not email_added_signal.send.called
assert not email_changed_signal.send.called
with patch("allauth.account.signals.email_added") as email_added_signal:
with patch("allauth.account.signals.email_changed") as email_changed_signal:
resp = auth_client.post(
reverse("account_email"), {"action_add": "", "email": email}
)
assert resp["location"] == reverse("account_email_verification_sent")
assert not email_added_signal.send.called
assert not email_changed_signal.send.called
assert EmailAddress.objects.filter(email=email).count() == 0
code = get_last_code()
resp = auth_client.get(reverse("account_email_verification_sent"))
assert resp.status_code == 200
with (
patch("allauth.account.signals.email_added") as email_added_signal,
patch("allauth.account.signals.email_changed") as email_changed_signal,
patch("allauth.account.signals.email_confirmed") as email_confirmed_signal,
):
resp = auth_client.post(
reverse("account_email_verification_sent"), data={"code": code}
)
assert resp.status_code == 302
assert resp["location"] == reverse("account_email")
assert email_added_signal.send.called
assert email_confirmed_signal.send.called
assert email_changed_signal.send.called == change_email
with patch("allauth.account.signals.email_added") as email_added_signal:
with patch("allauth.account.signals.email_changed") as email_changed_signal:
with patch(
"allauth.account.signals.email_confirmed"
) as email_confirmed_signal:
resp = auth_client.post(
reverse("account_email_verification_sent"), data={"code": code}
)
assert resp.status_code == 302
assert resp["location"] == reverse("account_email")
assert email_added_signal.send.called
assert email_confirmed_signal.send.called
assert email_changed_signal.send.called == change_email
assert EmailAddress.objects.filter(email=email, verified=True).count() == 1
assert EmailAddress.objects.filter(user=user).count() == (1 if change_email else 2)

Expand Down

0 comments on commit fc7627c

Please sign in to comment.