#NEWLINE# @ mock . patch ( 'yaml.load' , autospec = True ) #NEWLINE# @ mock . patch ( 'os.path.isfile' , autospec = True ) #NEWLINE# def test_load_config_files_multiple_files( self , mock_os_path_isfile , mock_yaml_load ) : #NEWLINE# #INDENT# mock_yaml_load . side_effect = [ { #NEWLINE# #INDENT# 'disk_images' : [ { #NEWLINE# #INDENT# 'arch' : 'amd64' , #NEWLINE# 'imagename' : 'overcloud' , #NEWLINE# 'distro' : 'some_awesome_distro' , #NEWLINE# 'type' : 'qcow2' , #NEWLINE# 'elements' : [ 'image_element' ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'disk_images' : [ { #NEWLINE# #INDENT# 'imagename' : 'overcloud' , #NEWLINE# 'elements' : [ 'another_image_element' ] , #NEWLINE# 'packages' : [ 'a_package' ] , #NEWLINE# 'otherkey' : 'some_other_key' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } ] #NEWLINE# mock_os_path_isfile . return_value = True #NEWLINE# mock_open_context = mock . mock_open ( ) #NEWLINE# mock_open_context ( ) . read . return_value = 'YAML' #NEWLINE# with mock . patch ( 'six.moves.builtins.open' , mock_open_context ) : #NEWLINE# #INDENT# base_manager = BaseImageManager ( [ 'yamlfile1' , 'yamlfile2' ] ) #NEWLINE# disk_images = base_manager . load_config_files ( 'disk_images' ) #NEWLINE# #UNINDENT# self . assertEqual ( 2 , mock_yaml_load . call_count ) #NEWLINE# self . assertEqual ( [ { #NEWLINE# #INDENT# 'arch' : 'amd64' , #NEWLINE# 'distro' : 'some_awesome_distro' , #NEWLINE# 'imagename' : 'overcloud' , #NEWLINE# 'type' : 'qcow2' , #NEWLINE# 'elements' : [ 'image_element' , 'another_image_element' ] , #NEWLINE# 'packages' : [ 'a_package' ] , #NEWLINE# 'otherkey' : 'some_other_key' , #NEWLINE# #UNINDENT# } ] , disk_images )