#NEWLINE# @ mock . patch . object ( sh , '_show_profile' ) #NEWLINE# @ mock . patch . object ( utils , 'format_parameters' ) #NEWLINE# @ mock . patch . object ( utils , 'process_stack_spec' ) #NEWLINE# @ mock . patch . object ( utils , 'get_spec_content' ) #NEWLINE# def test_do_profile_create( self , mock_get , mock_proc , mock_format , mock_show ) : #NEWLINE# #INDENT# args = copy . deepcopy ( self . profile_args ) #NEWLINE# args = self . _make_args ( args ) #NEWLINE# spec = copy . deepcopy ( self . profile_spec ) #NEWLINE# mock_get . return_value = service #NEWLINE# stack_properties = mock . Mock ( ) #NEWLINE# mock_proc . return_value = stack_properties #NEWLINE# mock_format . return_value = { #NEWLINE# #INDENT# 'user' : 'demo' , #NEWLINE# #UNINDENT# } #NEWLINE# params = { #NEWLINE# #INDENT# 'name' : 'stack_spec' , #NEWLINE# 'spec' : spec , #NEWLINE# 'metadata' : { #NEWLINE# #INDENT# 'user' : 'demo' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# service = mock . Mock ( ) #NEWLINE# profile = mock . Mock ( ) #NEWLINE# profile_id = mock . Mock ( ) #NEWLINE# profile . id = profile_id #NEWLINE# service . create_profile . return_value = profile #NEWLINE# sh . do_profile_create ( service , args ) #NEWLINE# mock_get . assert_called_once_with ( args . spec_file ) #NEWLINE# mock_proc . assert_called_once_with ( self . profile_spec [ 'properties' ] ) #NEWLINE# mock_format . assert_called_once_with ( args . metadata ) #NEWLINE# service . create_profile . assert_called_once_with ( ** params ) #NEWLINE# mock_show . assert_called_once_with ( service , profile_id ) #NEWLINE# del spec [ 'type' ] #NEWLINE# ex = self . assertRaises ( exc . CommandError , sh . do_profile_create , service , args ) #NEWLINE# self . assertEqual ( _ ( "Missing 'type' key in spec file." ) , six . text_type ( ex ) ) #NEWLINE# spec [ 'type' ] = 'os.heat.stack' #NEWLINE# del spec [ 'version' ] #NEWLINE# ex = self . assertRaises ( exc . CommandError , sh . do_profile_create , service , args ) #NEWLINE# self . assertEqual ( _ ( "Missing 'version' key in spec file." ) , six . text_type ( ex ) ) #NEWLINE# spec [ 'version' ] = 1.0 #NEWLINE# del spec [ 'properties' ] #NEWLINE# ex = self . assertRaises ( exc . CommandError , sh . do_profile_create , service , args ) #NEWLINE# self . assertEqual ( _ ( "Missing 'properties' key in spec file." ) , six . text_type ( ex ) )