#NEWLINE# def assert_user_access_to_permission_list( self , user , customer , should_see ) : #NEWLINE# #INDENT# self . client . force_authenticate ( user = actual_urls . users [ user ] ) #NEWLINE# response = self . client . get ( reverse ( 'customer_permission-list' ) ) #NEWLINE# self . assertEqual ( response . status_code , status . HTTP_200_OK ) #NEWLINE# expected_urls = { r : self . _get_permission_url ( * r ) for r in self . all_roles if ( r . customer == customer ) } #NEWLINE# actual_urls = set ( [ role [ 'url' ] for role in response . data ] ) #NEWLINE# for ( role , role_url ) in expected_urls . items ( ) : #NEWLINE# #INDENT# if should_see : #NEWLINE# #INDENT# self . assertIn ( role_url , actual_urls , '{0} user does not see privilege he is supposed to see: {1}' . format ( user , role ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertNotIn ( role_url , actual_urls , '{0} user sees privilege he is not supposed to see: {1}' . format ( user , role ) )