<s> from django . test import TestCase <EOL> from django . contrib . auth import get_user_model <EOL> from userena . backends import UserenaAuthenticationBackend <EOL> User = get_user_model ( ) <EOL> class UserenaAuthenticationBackendTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , ] <EOL> backend = UserenaAuthenticationBackend ( ) <EOL> def test_with_username ( self ) : <EOL> """<STR_LIT>""" <EOL> invalid_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 invalid_dict in invalid_data_dicts : <EOL> result = self . backend . authenticate ( identification = invalid_dict [ '<STR_LIT>' ] , <EOL> password = invalid_dict [ '<STR_LIT:password>' ] ) <EOL> self . assertFalse ( isinstance ( result , User ) ) <EOL> result = self . backend . authenticate ( identification = '<STR_LIT>' , <EOL> password = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( result , User ) ) <EOL> def test_with_email ( self ) : <EOL> """<STR_LIT>""" <EOL> invalid_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 invalid_dict in invalid_data_dicts : <EOL> result = self . backend . authenticate ( identification = invalid_dict [ '<STR_LIT>' ] , <EOL> password = invalid_dict [ '<STR_LIT:password>' ] ) <EOL> self . assertFalse ( isinstance ( result , User ) ) <EOL> result = self . backend . authenticate ( identification = '<STR_LIT>' , <EOL> password = '<STR_LIT>' ) <EOL> self . assertTrue ( isinstance ( result , User ) ) <EOL> def test_get_user ( self ) : <EOL> """<STR_LIT>""" <EOL> user = self . backend . get_user ( <NUM_LIT:1> ) <EOL> self . assertEqual ( user . username , '<STR_LIT>' ) <EOL> user = self . backend . get_user ( <NUM_LIT> ) <EOL> self . assertFalse ( user ) </s>
