#NEWLINE# @ mock . patch ( 'see.context.resources.vbox.libvirt' ) #NEWLINE# @ mock . patch ( 'see.context.resources.vbox.domain_create' ) #NEWLINE# @ mock . patch ( 'see.context.resources.vbox.domain_delete' ) #NEWLINE# def test_cleanup( self , delete_mock , create_mock , libvirt_mock ) : #NEWLINE# #INDENT# 'Resources are released on cleanup.' #NEWLINE# resources = vbox . VBoxResources ( 'foo' , { #NEWLINE# #INDENT# 'domain' : 'bar' , #NEWLINE# 'disk' : { #NEWLINE# #INDENT# 'image' : '/foo/bar' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# resources . _domain = mock . Mock ( ) #NEWLINE# resources . _hypervisor = mock . Mock ( ) #NEWLINE# resources . cleanup ( ) #NEWLINE# delete_mock . assert_called_with ( resources . domain , mock . ANY ) #NEWLINE# self . assertTrue ( delete_mock . _hypervisor . close . called )