<s> from django . test import TestCase <EOL> try : <EOL> from django . contrib . auth import get_user_model <EOL> User = get_user_model ( ) <EOL> except ImportError : <EOL> from django . contrib . auth . models import User <EOL> class TestSuBackend ( TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestSuBackend , self ) . setUp ( ) <EOL> from django_su . backends import SuBackend <EOL> self . user = User . objects . create ( username = '<STR_LIT>' ) <EOL> self . backend = SuBackend ( ) <EOL> def test_authenticate_do_it ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . authenticate ( su = True , user_id = self . user . pk ) , <EOL> self . user <EOL> ) <EOL> def test_authenticate_dont_do_it ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . authenticate ( su = False , user_id = self . user . pk ) , <EOL> None <EOL> ) <EOL> def test_authenticate_id_none ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . authenticate ( su = True , user_id = None ) , <EOL> None <EOL> ) <EOL> def test_authenticate_id_non_existent ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . authenticate ( su = True , user_id = <NUM_LIT> ) , <EOL> None <EOL> ) <EOL> def test_authenticate_id_invalid ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . authenticate ( su = True , user_id = '<STR_LIT:abc>' ) , <EOL> None <EOL> ) <EOL> def test_get_user_exists ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . get_user ( user_id = self . user . pk ) , <EOL> self . user <EOL> ) <EOL> def test_get_user_does_not_exist ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . backend . get_user ( user_id = <NUM_LIT> ) , <EOL> None <EOL> ) </s>
