Exemplo n.º 1
0
    def test_get_pstate_by_type_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_type(PowerStateType.SWITCHING_OFF)

        assert "not be found" in str(excinfo.value)
Exemplo n.º 2
0
 def test_get_pstate_by_type_must_return_all_matches(self):
     p1 = PowerState(0, PowerStateType.SLEEP, 10, 10)
     p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
     p3 = PowerState(2, PowerStateType.COMPUTATION, 1000, 10000)
     p4 = PowerState(3, PowerStateType.SWITCHING_OFF, 50, 50)
     p5 = PowerState(4, PowerStateType.SWITCHING_ON, 25, 25)
     h = Host(0, "n", pstates=[p1, p3, p2, p4, p5])
     pstates = h.get_pstate_by_type(PowerStateType.COMPUTATION)
     assert pstates == [p2, p3]
Exemplo n.º 3
0
    def test_get_pstate_by_type_not_defined_must_raise(self):
        h = Host(0, "n", pstates=[])
        with pytest.raises(RuntimeError) as excinfo:
            h.get_pstate_by_type(PowerStateType.SWITCHING_OFF)

        assert "undefined" in str(excinfo.value)