示例#1
0
    def test_get_pstate_by_id_not_found_must_raise(self):
        p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
        p3 = PowerState(2, PowerStateType.COMPUTATION, 1000, 10000)
        h = Host(0, "n", pstates=[p3, p2])

        with pytest.raises(LookupError) as excinfo:
            h.get_pstate_by_id(4)

        assert "not be found" in str(excinfo.value)
示例#2
0
 def test_get_pstate_by_id_not_defined_must_raise(self):
     h = Host(0, "n", pstates=[])
     with pytest.raises(RuntimeError) as excinfo:
         h.get_pstate_by_id(4)
     assert "undefined" in str(excinfo.value)
示例#3
0
 def test_get_pstate_by_id_valid(self):
     p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
     p3 = PowerState(2, PowerStateType.COMPUTATION, 1000, 10000)
     h = Host(0, "n", pstates=[p3, p2])
     assert h.get_pstate_by_id(1) == p2
     assert h.get_pstate_by_id(2) == p3