#NEWLINE# @ mock . patch . object ( vm_utils , 'get_vdi_for_vm_safely' ) #NEWLINE# @ mock . patch . object ( vm_utils , '_walk_vdi_chain' ) #NEWLINE# @ mock . patch . object ( vm_utils , '_delete_snapshots_in_vdi_chain' ) #NEWLINE# def test_remove_old_snapshots( self , mock_delete , mock_walk , mock_get ) : #NEWLINE# #INDENT# instance = { #NEWLINE# #INDENT# 'uuid' : 'fake' , #NEWLINE# #UNINDENT# } #NEWLINE# mock_get . return_value = ( 'ref' , { #NEWLINE# #INDENT# 'uuid' : 'vdi' , #NEWLINE# 'SR' : 'sr_ref' , #NEWLINE# #UNINDENT# } ) #NEWLINE# mock_walk . return_value = [ { #NEWLINE# #INDENT# 'uuid' : 'uuid1' , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'uuid' : 'uuid2' , #NEWLINE# #UNINDENT# } ] #NEWLINE# vm_utils . remove_old_snapshots ( 'session' , mock_delete , 'vm_ref' ) #NEWLINE# mock_delete . assert_called_once_with ( 'session' , instance , [ 'uuid1' , 'uuid2' ] , 'sr_ref' ) #NEWLINE# mock_get . assert_called_once_with ( 'session' , 'vm_ref' ) #NEWLINE# mock_walk . assert_called_once_with ( 'session' , 'vdi' )