def test_set_on_when_idle_must_raise(self): p1 = PowerState(0, PowerStateType.SLEEP, 10, 10) p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100) p3 = PowerState(2, PowerStateType.SWITCHING_OFF, 50, 50) p4 = PowerState(3, PowerStateType.SWITCHING_ON, 75, 75) h = Host(0, "n", pstates=[p1, p3, p2, p4]) with pytest.raises(SystemError) as excinfo: h._set_on() assert "switching on" in str(excinfo.value)
def test_set_on_valid(self): p1 = PowerState(0, PowerStateType.SLEEP, 10, 10) p2 = PowerState(1, PowerStateType.COMPUTATION, 10, 100) p3 = PowerState(3, PowerStateType.SWITCHING_OFF, 50, 50) p4 = PowerState(4, PowerStateType.SWITCHING_ON, 75, 75) h = Host(0, "n", pstates=[p1, p3, p2, p4]) h._switch_off() h._set_off() h._switch_on() h._set_on() assert h.is_idle and h.pstate == p2 and h.state == HostState.IDLE