Hello all,
I would like to unit test a django view by sumitting a form. The problem is that this form has a captcha field (based on django-simple-captcha).
from django import forms
from captcha.fields import CaptchaField
class ContactForm(forms.forms.Form):
"""
The information needed for being able to download
"""
lastname = forms.CharField(max_length=30, label='Last name')
firstname = forms.CharField(max_length=30, label='First name')
...
captcha = CaptchaField()
The test code:
class ContactFormTest(TestCase):
def test_submitform(self):
"""Test that the contact page"""
url = reverse('contact_form')
form_data = {}
form_data['firstname'] = 'Paul'
form_data['lastname'] = 'Macca'
form_data['captcha'] = '28if'
response = self.client.post(url, form_data, follow=True)
Is there any approach to unit-test this code and get rid of the captcha when testing?
Thanks in advance