@@ -82,9 +82,8 @@ def test_user_registration_success(self, mock_complete_signup, api_client_factor
8282 assert len (mail .outbox ) == 1
8383 assert mail .outbox [0 ].subject == '[example.com] Please Confirm Your Email Address'
8484
85- @patch ('allauth.account.utils.complete_signup' ) # Mock the complete_signup function
8685 @pytest .mark .django_db
87- def test_user_registration_validation_errors (self , mock_complete_signup , api_client_factory , url_factory , user_factory ):
86+ def test_user_registration_validation_errors (self , api_client_factory , url_factory , user_factory ):
8887 # Pick variables that you only need for registration form.
8988 user_exist_data = { k : v for k , v in model_to_dict (user_factory ).items () if k in ['name' , 'email' , 'phone_number' , 'password' ]}
9089 response = api_client_factory .post (url_factory ('register' ), user_exist_data )
@@ -98,3 +97,33 @@ def test_user_registration_validation_errors(self, mock_complete_signup, api_cli
9897 assert response .data ['email' ][0 ] == 'This field is required.'
9998 assert response .data ['phone_number' ][0 ] == 'This field is required.'
10099 assert response .data ['password' ][0 ] == 'This field is required.'
100+
101+
102+ class TestPasswordResetView :
103+ def test_password_reset_url (self , url_factory ):
104+ password_reset_url = url_factory ("password_reset" )
105+ assert password_reset_url == "/api/password/reset/"
106+
107+ @pytest .mark .django_db
108+ def test_password_reset_link_success (self , api_client_factory , url_factory , user_factory ):
109+ data = {
'email' :
'[email protected] ' }
110+ response = api_client_factory .post (url_factory ("password_reset" ), data )
111+ assert str (response .data ['email' ][0 ]) == 'User with this email address does not exist.'
112+
113+ # Use existing, registered user email
114+ data = {"email" : model_to_dict (user_factory )['email' ]}
115+ response = api_client_factory .post (url_factory ("password_reset" ), data )
116+ assert response .status_code == 200
117+
118+ # Check that the reset password email was sent.
119+ assert len (mail .outbox ) == 1
120+ assert mail .outbox [0 ].to [0 ] == data ['email' ]
121+
122+ class TestCustomPasswordResetFromKey :
123+ def test_custom_reset_password (self , url_factory ):
124+ pass
125+
126+
127+ class TestCustomConfirmEmailView :
128+ def test_confirm_email_url (self , url_factory ):
129+ pass
0 commit comments