#NEWLINE# def test_ceilometer( self ) : #NEWLINE# #INDENT# fake_ceilometer = fakes . FakeCeilometerClient ( ) #NEWLINE# mock_ceilometer = mock . MagicMock ( ) #NEWLINE# mock_ceilometer . client . get_client = mock . MagicMock ( return_value = fake_ceilometer ) #NEWLINE# self . assertNotIn ( 'ceilometer' , self . clients . cache ) #NEWLINE# with mock . patch . dict ( 'sys.modules' , { #NEWLINE# #INDENT# 'ceilometerclient' : mock_ceilometer , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# client = self . clients . ceilometer ( ) #NEWLINE# self . assertEqual ( fake_ceilometer , client ) #NEWLINE# self . service_catalog . url_for . assert_called_once_with ( service_type = 'metering' , endpoint_type = consts . EndpointType . PUBLIC , region_name = self . credential . region_name ) #NEWLINE# kw = { #NEWLINE# #INDENT# 'os_endpoint' : self . service_catalog . url_for . return_value , #NEWLINE# 'token' : self . fake_keystone . auth_token , #NEWLINE# 'timeout' : cfg . CONF . openstack_client_http_timeout , #NEWLINE# 'insecure' : False , #NEWLINE# 'cacert' : None , #NEWLINE# 'username' : self . credential . username , #NEWLINE# 'password' : self . credential . password , #NEWLINE# 'tenant_name' : self . credential . tenant_name , #NEWLINE# 'auth_url' : self . credential . auth_url , #NEWLINE# #UNINDENT# } #NEWLINE# mock_ceilometer . client . get_client . assert_called_once_with ( '2' , ** kw ) #NEWLINE# self . assertEqual ( kw , self . clients . cache [ 'ceilometer' ] )