#NEWLINE# @ mock . patch ( 'bareon.drivers.data.nailgun.Nailgun.parse_image_meta' , return_value = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# @ mock . patch ( 'bareon.drivers.data.nailgun.hu.list_block_devices' ) #NEWLINE# @ mock . patch . object ( partitioning , 'fu' , autospec = True ) #NEWLINE# def test_do_partitioning_with_keep_data_flag( self , mock_fu , mock_lbd , mock_image_meta ) : #NEWLINE# #INDENT# mock_lbd . return_value = test_nailgun . LIST_BLOCK_DEVICES_SAMPLE #NEWLINE# data = copy . deepcopy ( test_nailgun . PROVISION_SAMPLE_DATA ) #NEWLINE# for disk in volume [ 'ks_meta' ] [ 'pm_data' ] [ 'ks_spaces' ] : #NEWLINE# #INDENT# for volume in disk [ 'volumes' ] : #NEWLINE# #INDENT# if ( ( volume [ 'type' ] == 'pv' ) and ( volume [ 'vg' ] == 'image' ) ) : #NEWLINE# #INDENT# volume [ 'keep_data' ] = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . drv = nailgun . Nailgun ( data ) #NEWLINE# self . action = partitioning . PartitioningAction ( self . drv ) #NEWLINE# self . action . execute ( ) #NEWLINE# mock_fu_mf_expected_calls = [ mock . call ( 'ext2' , '' , '' , '/dev/sda3' ) , mock . call ( 'ext2' , '' , '' , '/dev/sda4' ) , mock . call ( 'swap' , '' , '' , '/dev/mapper/os-swap' ) ] #NEWLINE# self . assertEqual ( mock_fu_mf_expected_calls , mock_fu . make_fs . call_args_list )