Skip to content

Commit 61b9198

Browse files
committed
tests(headless): check authentication response during signup
1 parent 031e26b commit 61b9198

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

allauth/headless/account/tests/test_signup.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from django.contrib.auth.models import User
44

55
from allauth.account.models import EmailAddress, EmailConfirmationHMAC
6+
from allauth.account.signals import user_logged_in
7+
from allauth.headless.base.response import AuthenticationResponse
68
from allauth.headless.constants import Flow
79

810

@@ -15,17 +17,25 @@ def test_signup(
1517
headless_reverse,
1618
headless_client,
1719
):
18-
resp = client.post(
19-
headless_reverse("headless:account:signup"),
20-
data={
21-
"username": "wizard",
22-
"email": email_factory(),
23-
"password": password_factory(),
24-
},
25-
content_type="application/json",
26-
)
27-
assert resp.status_code == 200
28-
assert User.objects.filter(username="wizard").exists()
20+
def on_user_logged_in(**kwargs):
21+
response = kwargs["response"]
22+
assert isinstance(response, AuthenticationResponse)
23+
24+
user_logged_in.connect(on_user_logged_in)
25+
try:
26+
resp = client.post(
27+
headless_reverse("headless:account:signup"),
28+
data={
29+
"username": "wizard",
30+
"email": email_factory(),
31+
"password": password_factory(),
32+
},
33+
content_type="application/json",
34+
)
35+
assert resp.status_code == 200
36+
assert User.objects.filter(username="wizard").exists()
37+
finally:
38+
user_logged_in.disconnect(on_user_logged_in)
2939

3040

3141
def test_signup_with_email_verification(

0 commit comments

Comments
 (0)