3
3
from django .contrib .auth .models import User
4
4
5
5
from allauth .account .models import EmailAddress , EmailConfirmationHMAC
6
+ from allauth .account .signals import user_logged_in
7
+ from allauth .headless .base .response import AuthenticationResponse
6
8
from allauth .headless .constants import Flow
7
9
8
10
@@ -15,17 +17,25 @@ def test_signup(
15
17
headless_reverse ,
16
18
headless_client ,
17
19
):
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 )
29
39
30
40
31
41
def test_signup_with_email_verification (
0 commit comments