def test_delete_destroy(self): """Domain is destroyed if active.""" domain = mock.Mock() logger = mock.Mock() domain.isActive.return_value = True vbox.domain_delete(domain, logger) self.assertTrue(domain.destroy.called)
def test_delete_undefine(self): """Domain is undefined.""" domain = mock.Mock() logger = mock.Mock() domain.isActive.return_value = False vbox.domain_delete(domain, logger) self.assertTrue(domain.undefine.called)
def test_delete_destroy_error(self): """Domain destroy raises error.""" domain = mock.Mock() logger = mock.Mock() domain.isActive.return_value = True domain.destroy.side_effect = libvirt.libvirtError("BOOM") vbox.domain_delete(domain, logger) self.assertTrue(domain.undefine.called)
def test_delete_undefine_snapshots(self): """Domain undefine with snapshots metadata.""" domain = mock.Mock() logger = mock.Mock() domain.isActive.return_value = False domain.undefine.side_effect = libvirt.libvirtError("BOOM") vbox.domain_delete(domain, logger) domain.undefineFlags.assert_called_with(libvirt.VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA)
def test_delete_undefine_snapshots(self): """Domain undefine with snapshots metadata.""" domain = mock.Mock() logger = mock.Mock() domain.isActive.return_value = False domain.undefine.side_effect = libvirt.libvirtError("BOOM") vbox.domain_delete(domain, logger) domain.undefineFlags.assert_called_with( libvirt.VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA)