<s> from __future__ import unicode_literals <EOL> import re <EOL> import sys <EOL> from unittest import skipIf <EOL> from captcha . models import CaptchaStore <EOL> from django . test import TestCase <EOL> from django . utils . encoding import force_text <EOL> from dynamic_forms . formfields import formfield_registry as registry <EOL> from dynamic_forms . models import FormFieldModel , FormModel , FormModelData <EOL> @ skipIf ( sys . version_info [ : <NUM_LIT:2> ] == ( <NUM_LIT:3> , <NUM_LIT:2> ) , <EOL> '<STR_LIT>' ) <EOL> class TestSimpleCaptcha ( TestCase ) : <EOL> def setUp ( self ) : <EOL> from dynamic_forms . contrib . simple_captcha . models import CaptchaField <EOL> self . captcha_key = '<STR_LIT>' <EOL> def tearDown ( self ) : <EOL> registry . unregister ( self . captcha_key ) <EOL> def test_default ( self ) : <EOL> self . fm = FormModel . objects . create ( name = '<STR_LIT>' , submit_url = '<STR_LIT>' , <EOL> success_url = '<STR_LIT>' , <EOL> actions = [ '<STR_LIT>' ] , <EOL> form_template = '<STR_LIT>' , <EOL> success_template = '<STR_LIT>' ) <EOL> FormFieldModel . objects . create ( parent_form = self . fm , <EOL> field_type = '<STR_LIT>' , <EOL> label = '<STR_LIT>' , position = <NUM_LIT:1> ) <EOL> FormFieldModel . objects . create ( parent_form = self . fm , <EOL> field_type = self . captcha_key , <EOL> label = '<STR_LIT>' , position = <NUM_LIT:2> ) <EOL> response = self . client . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> regex = r'<STR_LIT>' <EOL> hash_ = re . findall ( regex , force_text ( response . content ) ) [ <NUM_LIT:0> ] <EOL> captcha_object = CaptchaStore . objects . get ( hashkey = hash_ ) <EOL> response = self . client . post ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : hash_ , <EOL> '<STR_LIT>' : captcha_object . challenge , <EOL> } ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> self . assertRedirects ( response , '<STR_LIT>' ) <EOL> data = FormModelData . objects . get ( ) <EOL> self . assertEqual ( data . value , '<STR_LIT>' ) </s>
