diff --git a/CHANGES.rst b/CHANGES.rst index 4db8962..3622074 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +Version 0.1.11 (2024-04-12) +-------------------------- + +* New: Add a new settings option FRC_CAPTCHA_MOCKED_VALUE for + testing purposes. + + Version 0.1.10 (2024-03-29) -------------------------- diff --git a/README.rst b/README.rst index dd74091..4982950 100644 --- a/README.rst +++ b/README.rst @@ -112,6 +112,15 @@ When setting FAIL_SILENT to True it's up to you to handle captcha verification: else: # captcha verification failed, do nothing ... +As of version 0.1.11 there's a new settings option to get a mocked +value from the captcha verification. You can set FRC_CAPTCHA_MOCKED_VALUE +to True or False, depending on the vaule you need for testing. +The default value is unset which equals to None. + +.. code-block:: + + FRC_CAPTCHA_MOCKED_VALUE = None|False|True + Custom widget attributes ######################## diff --git a/friendly_captcha/fields.py b/friendly_captcha/fields.py index 2bfa5e7..18ba8e1 100644 --- a/friendly_captcha/fields.py +++ b/friendly_captcha/fields.py @@ -19,6 +19,13 @@ def __init__(self, *args, **kwargs): super(FrcCaptchaField, self).__init__(*args, **kwargs) def clean(self, value): + # Mock the response of verification for testing purposes + mocked_value = getattr(settings, 'FRC_CAPTCHA_MOCKED_VALUE', None) + print('mocked value', mocked_value) + if mocked_value is not None: + logger.info('Captcha mocked value set to %s', mocked_value) + return mocked_value + clean_value = False # handle captcha field captcha_secret = getattr(settings, 'FRC_CAPTCHA_SECRET', None) diff --git a/friendly_captcha/tests.py b/friendly_captcha/tests.py index 7ce503c..a79ca8b 100644 --- a/friendly_captcha/tests.py +++ b/friendly_captcha/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/setup.py b/setup.py index 68c261f..73f29be 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(fname): setup( name='django-friendly-captcha', - version='0.1.10', + version='0.1.11', description='Django library for friendly captcha', long_description=read('README.rst'), long_description_content_type='text/x-rst', @@ -37,6 +37,8 @@ def read(fname): 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], zip_safe=False, )