#NEWLINE# @ mock . patch . object ( shutil , 'rmtree' , autospec = True ) #NEWLINE# @ mock . patch . object ( tempfile , 'mkdtemp' , autospec = True ) #NEWLINE# @ mock . patch . object ( utils , '_get_vmedia_device' ) #NEWLINE# @ mock . patch . object ( utils , '_read_params_from_file' ) #NEWLINE# @ mock . patch . object ( os . path , 'exists' ) #NEWLINE# @ mock . patch . object ( os , 'mkdir' ) #NEWLINE# @ mock . patch . object ( utils , 'execute' ) #NEWLINE# def test__get_vmedia_params_umount_fails( self , execute_mock , mkdir_mock , exists_mock , read_params_mock , get_device_mock , mkdtemp_mock , rmtree_mock ) : #NEWLINE# #INDENT# mkdtemp_mock . return_value = '/tempdir' #NEWLINE# null_output = [ '' , '' ] #NEWLINE# expected_params = { #NEWLINE# #INDENT# 'a' : 'b' , #NEWLINE# #UNINDENT# } #NEWLINE# exists_mock . return_value = True #NEWLINE# read_params_mock . return_value = expected_params #NEWLINE# get_device_mock . return_value = 'sda' #NEWLINE# execute_mock . side_effect = [ null_output , processutils . ProcessExecutionError ( ) ] #NEWLINE# returned_params = utils . _get_vmedia_params ( ) #NEWLINE# execute_mock . assert_any_call ( 'mount' , '/dev/disk/by-label/ir-vfd-dev' , '/tempdir' ) #NEWLINE# read_params_mock . assert_called_once_with ( '/tempdir/parameters.txt' ) #NEWLINE# execute_mock . assert_any_call ( 'umount' , '/tempdir' ) #NEWLINE# self . assertEqual ( expected_params , returned_params ) #NEWLINE# mkdtemp_mock . assert_called_once_with ( ) #NEWLINE# rmtree_mock . assert_called_once_with ( '/tempdir' )