Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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")
Esempio n. 4
0
 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")
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
    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)
Esempio n. 10
0
    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)