def test_destroy_registered(self): with conttestlib.tmp_run_dir(): dom = domain.Domain.create(conttestlib.minimal_dom_xml()) existing_doms = doms.get_all() self.assertEquals(len(existing_doms), 1) self.assertEquals(dom.ID, existing_doms[0].ID) dom.destroy() self.assertEquals(doms.get_all(), [])
def test_destroy_registered(self): with conttestlib.tmp_run_dir(): dom = domain.Domain.create( conttestlib.minimal_dom_xml() ) existing_doms = doms.get_all() self.assertEqual(len(existing_doms), 1) self.assertEqual(dom.ID, existing_doms[0].ID) dom.destroy() self.assertEqual(doms.get_all(), [])
def test_get_all(self): dom_list = _fill_doms(NUM) all_doms = doms.get_all() self.assertEqual(len(all_doms), len(dom_list)) dom_uuids = set(d.uuid for d in dom_list) for dom in all_doms: self.assertIn(dom.UUIDString(), dom_uuids)
def test_remove(self): dom_list = _fill_doms(NUM) # random pick doms.remove(dom_list[2].uuid) for dom in doms.get_all(): # FIXME: better avoid this. self.assertNotEquals(dom.UUIDString(), dom_list[2].uuid)
def test_destroy_unregistered(self): # you need to call create() to register into `doms'. with conttestlib.tmp_run_dir(): dom = domain.Domain(conttestlib.minimal_dom_xml()) self.assertEquals(doms.get_all(), []) self.assertRaises(libvirt.libvirtError, dom.destroy)
def test_destroy_unregistered(self): # you need to call create() to register into `doms'. with conttestlib.tmp_run_dir(): dom = domain.Domain( conttestlib.minimal_dom_xml() ) self.assertEqual(doms.get_all(), []) self.assertRaises(libvirt.libvirtError, dom.destroy)
def test_recover(self): vm_uuid = str(uuid.uuid4()) def _wrap(rt_uuid=None): self.runtime = ResyncingRuntime(rt_uuid) return self.runtime with conttestlib.tmp_run_dir(): with MonkeyPatchScope([(docker, 'Runtime', _wrap)]): domain.Domain.recover( vm_uuid, conttestlib.minimal_dom_xml(vm_uuid), ) existing_doms = doms.get_all() self.assertEquals(len(existing_doms), 1) self.assertEquals(existing_doms[0].UUIDString(), vm_uuid) self.assertTrue(self.runtime.recovered)
def test_recover(self): vm_uuid = str(uuid.uuid4()) def _wrap(rt_uuid=None): self.runtime = ResyncingRuntime(rt_uuid) return self.runtime with conttestlib.tmp_run_dir(): with MonkeyPatchScope([ (docker, 'Runtime', _wrap) ]): domain.Domain.recover( vm_uuid, conttestlib.minimal_dom_xml(vm_uuid), ) existing_doms = doms.get_all() self.assertEqual(len(existing_doms), 1) self.assertEqual(existing_doms[0].UUIDString(), vm_uuid) self.assertTrue(self.runtime.recovered)
def test_empty(self): self.assertEqual(doms.get_all(), [])