#NEWLINE# def _test_extend_volumes( self , extend = True , fail = False , size_ret = 0 , resize_ret = 0 ) : #NEWLINE# #INDENT# volume_indexes = [ 1 , 3 ] #NEWLINE# volumes = [ mock . Mock ( ) , mock . Mock ( ) , mock . Mock ( ) ] #NEWLINE# partitions = [ mock . Mock ( ) ] #NEWLINE# for volume in volumes : #NEWLINE# #INDENT# volume . associators . return_value = partitions #NEWLINE# #UNINDENT# for partition in partitions : #NEWLINE# #INDENT# size_max = partition . Size = 100 #NEWLINE# if extend : #NEWLINE# #INDENT# size_max = ( partition . Size + 10 ) #NEWLINE# #UNINDENT# partition . GetSupportedSize . return_value = [ size_ret , mock . Mock ( ) , size_max , mock . Mock ( ) ] #NEWLINE# partition . Resize . return_value = [ resize_ret , mock . Mock ( ) ] #NEWLINE# #UNINDENT# conn = self . mock_wmi . WMI . return_value #NEWLINE# conn . MSFT_Volume . return_value = volumes #NEWLINE# if fail : #NEWLINE# #INDENT# if ( size_ret or extend ) : #NEWLINE# #INDENT# with self . assertRaises ( exception . CloudbaseInitException ) : #NEWLINE# #INDENT# self . wsm . extend_volumes ( volume_indexes = volume_indexes ) #NEWLINE# #UNINDENT# #UNINDENT# return #NEWLINE# #UNINDENT# self . wsm . extend_volumes ( volume_indexes = volume_indexes ) #NEWLINE# conn . MSFT_Volume . assert_called_once_with ( ) #NEWLINE# for idx in volume_indexes : #NEWLINE# #INDENT# volumes [ ( idx - 1 ) ] . associators . assert_called_once_with ( wmi_result_class = 'MSFT_Partition' ) #NEWLINE# #UNINDENT# volumes [ 1 ] . associators . assert_not_called ( ) #NEWLINE# for partition in partitions : #NEWLINE# #INDENT# calls = ( [ mock . call ( ) ] * len ( volume_indexes ) ) #NEWLINE# partition . GetSupportedSize . assert_has_calls ( calls ) #NEWLINE# #UNINDENT# if ( not extend ) : #NEWLINE# #INDENT# for partition in partitions : #NEWLINE# #INDENT# partition . Resize . assert_not_called ( ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# for partition in partitions : #NEWLINE# #INDENT# size_max = partition . GetSupportedSize . return_value [ 2 ] #NEWLINE# calls = ( [ mock . call ( size_max ) ] * len ( volume_indexes ) ) #NEWLINE# partition . Resize . assert_has_calls ( calls )