<s> from django . test import TestCase <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from userena import forms <EOL> from userena import settings as userena_settings <EOL> from userena . utils import get_user_model <EOL> class SignupFormTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def test_signup_form ( self ) : <EOL> """<STR_LIT>""" <EOL> invalid_data_dicts = [ <EOL> { '<STR_LIT:data>' : { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:username>' , [ _ ( u'<STR_LIT>' ) ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT>' , [ _ ( u'<STR_LIT>' ) ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:username>' , [ _ ( u'<STR_LIT>' ) ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:username>' , [ _ ( u'<STR_LIT>' ) ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:email>' , [ _ ( u'<STR_LIT>' ) ] ) } , <EOL> ] <EOL> for invalid_dict in invalid_data_dicts : <EOL> form = forms . SignupForm ( data = invalid_dict [ '<STR_LIT:data>' ] ) <EOL> self . failIf ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . errors [ invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:0> ] ] , <EOL> invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:1> ] ) <EOL> form = forms . SignupForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , <EOL> '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . failUnless ( form . is_valid ( ) ) <EOL> class AuthenticationFormTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , ] <EOL> def test_signin_form ( self ) : <EOL> """<STR_LIT>""" <EOL> invalid_data_dicts = [ <EOL> { '<STR_LIT:data>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT>' , [ u'<STR_LIT>' ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT>' , [ u'<STR_LIT>' ] ) } <EOL> ] <EOL> for invalid_dict in invalid_data_dicts : <EOL> form = forms . AuthenticationForm ( data = invalid_dict [ '<STR_LIT:data>' ] ) <EOL> self . failIf ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . errors [ invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:0> ] ] , <EOL> invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:1> ] ) <EOL> valid_data_dicts = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:password>' : '<STR_LIT>' } <EOL> ] <EOL> for valid_dict in valid_data_dicts : <EOL> form = forms . AuthenticationForm ( valid_dict ) <EOL> self . failUnless ( form . is_valid ( ) ) <EOL> def test_signin_form_email ( self ) : <EOL> """<STR_LIT>""" <EOL> userena_settings . USERENA_WITHOUT_USERNAMES = True <EOL> form = forms . AuthenticationForm ( data = { '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:password>' : "<STR_LIT>" } ) <EOL> correct_label = "<STR_LIT>" <EOL> self . assertEqual ( form . fields [ '<STR_LIT>' ] . label , <EOL> correct_label ) <EOL> userena_settings . USERENA_WITHOUT_USERNAMES = False <EOL> class SignupFormOnlyEmailTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def test_signup_form_only_email ( self ) : <EOL> """<STR_LIT>""" <EOL> valid_data = { '<STR_LIT:email>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> form = forms . SignupFormOnlyEmail ( data = valid_data ) <EOL> self . failIf ( form . fields . get ( '<STR_LIT:username>' , False ) ) <EOL> self . failUnless ( form . is_valid ( ) ) <EOL> user = form . save ( ) <EOL> self . failUnless ( len ( user . username ) , <NUM_LIT:5> ) <EOL> class ChangeEmailFormTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' ] <EOL> def test_change_email_form ( self ) : <EOL> user = get_user_model ( ) . objects . get ( pk = <NUM_LIT:1> ) <EOL> invalid_data_dicts = [ <EOL> { '<STR_LIT:data>' : { '<STR_LIT:email>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:email>' , [ u'<STR_LIT>' ] ) } , <EOL> { '<STR_LIT:data>' : { '<STR_LIT:email>' : '<STR_LIT>' } , <EOL> '<STR_LIT:error>' : ( '<STR_LIT:email>' , [ u'<STR_LIT>' ] ) } , <EOL> ] <EOL> for invalid_dict in invalid_data_dicts : <EOL> form = forms . ChangeEmailForm ( user , data = invalid_dict [ '<STR_LIT:data>' ] ) <EOL> self . failIf ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . errors [ invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:0> ] ] , <EOL> invalid_dict [ '<STR_LIT:error>' ] [ <NUM_LIT:1> ] ) <EOL> form = forms . ChangeEmailForm ( user , <EOL> data = { '<STR_LIT:email>' : '<STR_LIT>' } ) <EOL> self . failUnless ( form . is_valid ( ) ) <EOL> def test_form_init ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertRaises ( TypeError , forms . ChangeEmailForm , None ) <EOL> class EditAccountFormTest ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
