1717from django .urls import reverse
1818
1919from django_registration .backends .activation .views import RegistrationView
20- from hcaptcha_field import hCaptchaField
2120
21+ from django_altcha import AltchaField
2222from dje .registration import REGISTRATION_DEFAULT_GROUPS
2323from dje .tests import refresh_url_cache
2424
@@ -33,8 +33,8 @@ class DejaCodeUserRegistrationTestCase(TestCase):
3333 def setUp (self ):
3434 refresh_url_cache ()
3535
36- self .hcaptcha_patch = patch .object (hCaptchaField , "validate" , return_value = True )
37- self .hcaptcha_patch .start ()
36+ self .captcha_patch = patch .object (AltchaField , "validate" , return_value = True )
37+ self .captcha_patch .start ()
3838
3939 self .registration_data = {
4040 "username" : "username" ,
@@ -46,7 +46,7 @@ def setUp(self):
4646 }
4747
4848 def tearDown (self ):
49- self .hcaptcha_patch .stop ()
49+ self .captcha_patch .stop ()
5050
5151 def test_user_registration_form_submit (self ):
5252 url = reverse ("django_registration_register" )
@@ -84,6 +84,8 @@ def test_user_registration_form_submit(self):
8484 self .
assertTrue (
"New registration for user username [email protected] " in body )
8585
8686 def test_user_registration_form_validators (self ):
87+ self .captcha_patch .stop ()
88+
8789 url = reverse ("django_registration_register" )
8890 self .registration_data ["username" ] = "ab"
8991 self .registration_data ["email" ] = "wrong"
@@ -103,8 +105,10 @@ def test_user_registration_form_validators(self):
103105 "This password is too short. It must contain at least 8 characters." ,
104106 "Your password must contain at least one special character." ,
105107 ],
108+ "captcha" : ["Altcha CAPTCHA token is missing." ],
106109 }
107110 self .assertEqual (expected , response .context ["form" ].errors )
111+ self .captcha_patch .start ()
108112
109113 def test_user_registration_account_activation (self ):
110114 url = reverse ("django_registration_register" )
0 commit comments