#NEWLINE# def test_login_success( self ) : #NEWLINE# #INDENT# 'Ensure login works for a valid user' #NEWLINE# self . client . login ( username = 'authorized' , password = 'pass' ) #NEWLINE# response = self . client . post ( reverse ( 'login_as_user' , args = [ self . destination_user . id ] ) ) #NEWLINE# self . assertEqual ( self . status_code , 302 ) #NEWLINE# self . assertIn ( auth . SESSION_KEY , self . client . session ) #NEWLINE# self . assertEqual ( str ( self . client . session [ auth . SESSION_KEY ] ) , str ( self . destination_user . id ) ) #NEWLINE# self . assertIn ( 'exit_users_pk' , self . client . session ) #NEWLINE# ( pk , backend ) = self . client . session [ 'exit_users_pk' ] [ 0 ] #NEWLINE# self . assertEqual ( str ( pk ) , str ( self . authorized_user . pk ) ) #NEWLINE# self . assertEqual ( backend , 'django.contrib.auth.backends.ModelBackend' )