#NEWLINE# def test_validate_plan( self ) : #NEWLINE# #INDENT# self . plan_store . get = mock . MagicMock ( return_value = self . expected_plan ) #NEWLINE# self . expected_plan . files [ 'another-root-template.yaml' ] = { #NEWLINE# #INDENT# 'contents' : 'some fake contents' , #NEWLINE# 'meta' : { #NEWLINE# #INDENT# 'file-type' : 'root-template' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# plan_mgr = plan . PlanManager ( self . plan_store , self . heatclient ) #NEWLINE# self . assertRaises ( exception . TooManyRootTemplatesError , plan_mgr . validate_plan , self . plan_name ) #NEWLINE# del self . expected_plan . files [ 'another-root-template.yaml' ] #NEWLINE# with mock . patch ( 'tripleo_common.utils.templates' ) as templates : #NEWLINE# #INDENT# templates . process_plan_data = mock . MagicMock ( return_value = ( 'some fake contents' , { #NEWLINE# #INDENT# 'parameters' : { #NEWLINE# #INDENT# 'obj' : { #NEWLINE# #INDENT# 'two' : 'due' , #NEWLINE# 'three' : 'tre' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'one' : 'uno' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'some-template.yaml' : 'some fake contents' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . heatclient . stacks . validate = mock . MagicMock ( ) #NEWLINE# plan_mgr . validate_plan ( self . plan_name ) #NEWLINE# self . heatclient . stacks . validate . assert_called_with ( template = 'some fake contents' , files = { #NEWLINE# #INDENT# 'some-template.yaml' : 'some fake contents' , #NEWLINE# #UNINDENT# } , environment = { #NEWLINE# #INDENT# 'parameters' : { #NEWLINE# #INDENT# 'obj' : { #NEWLINE# #INDENT# 'two' : 'due' , #NEWLINE# 'three' : 'tre' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'one' : 'uno' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , show_nested = True ) #NEWLINE# self . heatclient . stacks . validate = mock . Mock ( side_effect = heatexceptions . HTTPBadRequest ) #NEWLINE# with mock . patch ( 'tripleo_common.core.plan.LOG' ) as log_mock : #NEWLINE# #INDENT# self . assertRaises ( exception . HeatValidationFailedError , plan_mgr . validate_plan , self . plan_name ) #NEWLINE# log_mock . exception . assert_called_with ( 'Error validating the plan.' )