Exemplo n.º 1
0
 def test_set_computation_state_not_found_must_raise(self):
     p1 = PowerState(0, PowerStateType.COMPUTATION, 10, 100)
     p2 = PowerState(1, PowerStateType.COMPUTATION, 15, 150)
     h = Host(0, "n", pstates=[p1, p2])
     with pytest.raises(LookupError) as excinfo:
         h._set_computation_pstate(2)
     assert "not be found" in str(excinfo.value)
Exemplo n.º 2
0
    def test_set_computation_state_valid(self):
        p1 = PowerState(0, PowerStateType.COMPUTATION, 10, 100)
        p2 = PowerState(1, PowerStateType.COMPUTATION, 15, 150)
        h = Host(0, "n", pstates=[p1, p2])
        h._set_computation_pstate(1)

        assert h.pstate == p2
Exemplo n.º 3
0
 def test_set_computation_state_not_correct_type_must_raise(self):
     p1 = PowerState(0, PowerStateType.SLEEP, 10, 10)
     p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
     p3 = PowerState(2, PowerStateType.COMPUTATION, 15, 150)
     p4 = PowerState(3, PowerStateType.SWITCHING_OFF, 50, 50)
     p5 = PowerState(4, PowerStateType.SWITCHING_ON, 75, 75)
     h = Host(0, "n", pstates=[p1, p3, p2, p4, p5])
     with pytest.raises(RuntimeError) as excinfo:
         h._set_computation_pstate(0)
     assert "computation" in str(excinfo.value)
Exemplo n.º 4
0
 def test_set_computation_state_when_switching_off_must_raise(self):
     p1 = PowerState(0, PowerStateType.SLEEP, 10, 10)
     p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
     p3 = PowerState(2, PowerStateType.COMPUTATION, 15, 150)
     p4 = PowerState(3, PowerStateType.SWITCHING_OFF, 50, 50)
     p5 = PowerState(4, PowerStateType.SWITCHING_ON, 75, 75)
     h = Host(0, "n", pstates=[p1, p3, p2, p4, p5])
     h._switch_off()
     with pytest.raises(RuntimeError) as excinfo:
         h._set_computation_pstate(2)
     assert "idle or computing" in str(excinfo.value)
Exemplo n.º 5
0
    def test_set_computation_state_when_computing_valid(self):
        p1 = PowerState(0, PowerStateType.SLEEP, 10, 10)
        p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100)
        p3 = PowerState(2, PowerStateType.COMPUTATION, 15, 150)
        p4 = PowerState(3, PowerStateType.SWITCHING_OFF, 50, 50)
        p5 = PowerState(4, PowerStateType.SWITCHING_ON, 75, 75)
        h = Host(0, "n", pstates=[p1, p3, p2, p4, p5])

        h._allocate("job")
        h._start_computing()
        h._set_computation_pstate(2)
        assert h.pstate == p3 and h.power == p3.watt_full
Exemplo n.º 6
0
 def test_set_computation_state_not_defined_must_raise(self):
     h = Host(0, "n", pstates=[])
     with pytest.raises(RuntimeError) as excinfo:
         h._set_computation_pstate(2)
     assert "undefined" in str(excinfo.value)