def test_currentStateIsStopped_inputInvalidCommandForThisState_raiseException(self): with self.assertRaises(ValueError): state_table.get_next_state(MachineState.STOPPED, MachineCommand.PROCESS)
def set_current_state(self, command): if not MachineCommand.contains(command): raise ValueError('Invalid command!') self._previous_state = self._state self._state = state_table.get_next_state(self._state, command)
def test_currentStateIsProcessing_inputStop_returnsStopped(self): actual_state = state_table.get_next_state(MachineState.PROCESSING, MachineCommand.STOP) assert_that(MachineState.STOPPED).is_equal_to(actual_state)
def test_currentStateIsCollecting_inputStop_returnsStopped(self): actual_state = state_table.get_next_state(MachineState.COLLECTING, MachineCommand.STOP) assert_that(MachineState.STOPPED).is_equal_to(actual_state)
def test_currentStateIsCollecting_inputProcess_returnsProcessing(self): actual_state = state_table.get_next_state(MachineState.COLLECTING, MachineCommand.PROCESS) assert_that(MachineState.PROCESSING).is_equal_to(actual_state)
def test_currentStateIsStarted_inputStop_returnsStopped(self): actual_state = state_table.get_next_state(MachineState.STARTED, MachineCommand.STOP) assert_that(MachineState.STOPPED).is_equal_to(actual_state)
def test_currentStateIsStarted_inputCollect_returnsCollecting(self): actual_state = state_table.get_next_state(MachineState.STARTED, MachineCommand.COLLECT) assert_that(MachineState.COLLECTING).is_equal_to(actual_state)