<s> from django . test import TestCase <EOL> from django . test . utils import override_settings <EOL> from . factories import InactiveUserFactory <EOL> from . factories import UserFactory <EOL> from mama_cas . forms import LoginForm <EOL> from mama_cas . forms import LoginFormEmail <EOL> class LoginFormTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . user = UserFactory ( ) <EOL> def test_login_form ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> def test_login_form_empty ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> def test_login_form_invalid ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> @ override_settings ( AUTHENTICATION_BACKENDS = ( '<STR_LIT>' , ) ) <EOL> def test_login_form_exception ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> @ override_settings ( AUTHENTICATION_BACKENDS = ( '<STR_LIT>' , ) ) <EOL> def test_login_case_insensitive ( self ) : <EOL> """<STR_LIT>""" <EOL> UserFactory ( first_name = '<STR_LIT>' , last_name = '<STR_LIT>' ) <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> def test_login_form_inactive ( self ) : <EOL> """<STR_LIT>""" <EOL> InactiveUserFactory ( ) <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> @ override_settings ( MAMA_CAS_ALLOW_AUTH_WARN = True ) <EOL> def test_login_form_warn ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginForm ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( '<STR_LIT>' in form . fields ) <EOL> def test_login_form_email ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginFormEmail ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> self . assertEqual ( form . cleaned_data [ '<STR_LIT:username>' ] , '<STR_LIT>' ) <EOL> def test_login_form_invalid_username_clean ( self ) : <EOL> """<STR_LIT>""" <EOL> form = LoginFormEmail ( data = { '<STR_LIT:username>' : '<STR_LIT>' , '<STR_LIT:password>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) </s>
