Closed christophhalbi closed 6 months ago
Unfortunately no, at least not at the moment. Just looked up, what I've done to solve that. I had added a setting to my app, that shall configure if the captcha should be used or not. I have a contact form that uses some different checking mechanisms like captcha or honeypot. So I created settings like i.e. CONTACT_USE_CAPTCHA. You can look up that form code in my gist: https://gist.github.com/christianwgd/81af2fc7a3dbb13d0adc1cf3a609662d
But it may be a good idea to add that to the library. I will think about that.
After studying friendly captcha's docs again, I would stick to the their recommendation to mock the verification API (https://docs.friendlycaptcha.com/#/automated_testing).
You could do that by setting FRC_CAPTCHA_VERIFICATION_URL. So just create some javascript API mock that simply returns {success: true}
or {success: false}
, just what your test case needs and set the FRC_CAPTCHA_VERIFICATION_URL to the desired javascript file (i.e. using the override_settings
decorator: https://docs.djangoproject.com/en/5.0/topics/testing/tools/#django.test.override_settings).
To keep it a little bit simpler for you all I just added a new setting to the module to version 0.1.11. You now can set FRC_CAPTCHA_MOCKED_VALUE to True or False depending on what exactly you want to test. The captcha validation will return the value of FRC_CAPTCHA_MOCKED_VALUE without reaching out to the friendly captcha verification API.
If this is sufficient for you, please let me know, so I can close this issue, thanks.
Sounds good. Thank you
Hi,
Is there any way I can skip the validation when running tests?