def test_add_hypervisor(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) self.assertEqual(model.get_hypervisor_from_id(id), hypervisor)
def test_assert_hypervisor_raise(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) self.assertRaises(IllegalArgumentException, model.assert_hypervisor, "objet_qcq")
def test_hypervisor_from_id_raise(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) id2 = "{0}".format(uuid.uuid4()) self.assertRaises(exception.HypervisorNotFound, model.get_hypervisor_from_id, id2)
def test_set_get_state_hypervisors(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) self.assertIsInstance(hypervisor.state, HypervisorState) hyp = model.get_hypervisor_from_id(id) hyp.state = HypervisorState.OFFLINE self.assertIsInstance(hyp.state, HypervisorState)
def test_remove_hypervisor_raise(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) id2 = "{0}".format(uuid.uuid4()) hypervisor2 = Hypervisor() hypervisor2.uuid = id2 self.assertRaises(exception.HypervisorNotFound, model.remove_hypervisor, hypervisor2)
def test_get_all_hypervisors(self): model = ModelRoot() for i in range(10): id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) all_hypervisors = model.get_all_hypervisors() for id in all_hypervisors: hyp = model.get_hypervisor_from_id(id) model.assert_hypervisor(hyp)
def test_delete_hypervisor(self): model = ModelRoot() id = "{0}".format(uuid.uuid4()) hypervisor = Hypervisor() hypervisor.uuid = id model.add_hypervisor(hypervisor) self.assertEqual(model.get_hypervisor_from_id(id), hypervisor) model.remove_hypervisor(hypervisor) self.assertRaises(exception.HypervisorNotFound, model.get_hypervisor_from_id, id)
def test_assert_vm_raise(self): model = ModelRoot() self.assertRaises(IllegalArgumentException, model.assert_vm, "valeur_qcq")