#NEWLINE# @ mock . patch ( 'glanceclient.Client' ) #NEWLINE# def test_headers_passed_glanceclient( self , init_mock ) : #NEWLINE# #INDENT# self . flags ( auth_strategy = 'keystone' ) #NEWLINE# auth_token = 'token' #NEWLINE# ctx = context . RequestContext ( 'fake' , 'fake' , auth_token = auth_token ) #NEWLINE# expected_endpoint = 'http://host4:9295' #NEWLINE# expected_params = { #NEWLINE# #INDENT# 'identity_headers' : { #NEWLINE# #INDENT# 'X-Auth-Token' : 'token' , #NEWLINE# 'X-User-Id' : 'fake' , #NEWLINE# 'X-Roles' : '' , #NEWLINE# 'X-Tenant-Id' : 'fake' , #NEWLINE# 'X-Identity-Status' : 'Confirmed' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# glance . _glanceclient_from_endpoint ( ctx , expected_endpoint ) #NEWLINE# init_mock . assert_called_once_with ( '1' , expected_endpoint , ** expected_params ) #NEWLINE# init_mock . reset_mock ( ) #NEWLINE# expected_endpoint = 'http://host4:9295' #NEWLINE# expected_params = { #NEWLINE# #INDENT# 'identity_headers' : { #NEWLINE# #INDENT# 'X-Auth-Token' : 'token' , #NEWLINE# 'X-User-Id' : 'fake' , #NEWLINE# 'X-Roles' : '' , #NEWLINE# 'X-Tenant-Id' : 'fake' , #NEWLINE# 'X-Identity-Status' : 'Confirmed' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# glance . _glanceclient_from_endpoint ( ctx , expected_endpoint , version = 2 ) #NEWLINE# init_mock . assert_called_once_with ( '2' , expected_endpoint , ** expected_params ) #NEWLINE# init_mock . reset_mock ( ) #NEWLINE# expected_endpoint = 'http://[host4]:9295' #NEWLINE# glance . _glanceclient_from_endpoint ( ctx , ctx ) #NEWLINE# init_mock . assert_called_once_with ( '1' , expected_endpoint , ** expected_params )