#NEWLINE# def test_ironic( self ) : #NEWLINE# #INDENT# fake_ironic = fakes . FakeIronicClient ( ) #NEWLINE# mock_ironic = mock . MagicMock ( ) #NEWLINE# mock_ironic . client . get_client = mock . MagicMock ( return_value = fake_ironic ) #NEWLINE# self . assertNotIn ( 'ironic' , self . clients . cache ) #NEWLINE# with mock . patch . dict ( 'sys.modules' , { #NEWLINE# #INDENT# 'ironicclient' : mock_ironic , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# client = self . clients . ironic ( ) #NEWLINE# self . assertEqual ( fake_ironic , client ) #NEWLINE# self . service_catalog . url_for . assert_called_once_with ( service_type = 'baremetal' , endpoint_type = consts . EndpointType . PUBLIC , region_name = self . credential . region_name ) #NEWLINE# kw = { #NEWLINE# #INDENT# 'os_auth_token' : self . fake_keystone . auth_token , #NEWLINE# 'ironic_url' : self . service_catalog . url_for . return_value , #NEWLINE# 'timeout' : cfg . CONF . openstack_client_http_timeout , #NEWLINE# 'insecure' : self . credential . insecure , #NEWLINE# 'cacert' : fake_ironic . credential . cacert , #NEWLINE# #UNINDENT# } #NEWLINE# mock_ironic . client . get_client . assert_called_once_with ( '1' , ** kw ) #NEWLINE# self . assertEqual ( fake_ironic , self . clients . cache [ 'ironic' ] )