def test_can_fire_event_with_name_failure_with_invalid_event(self): start_state = State(name='start') busy_state = State(name='busy') do_work_event = Event(name='do_work', source_states=[busy_state], destination_state=busy_state) fsm = StateMachine(states=[start_state, busy_state], events=[do_work_event], initial_state=start_state) fsm.activate() with pytest.raises(StateMachineError) as context: fsm.can_fire_event_with_name('no_work') expected_exception = context.value assert expected_exception.identifier == STATE_MACHINE.EVENT_NOT_FOUND_IDENTIFIER
def test_can_fire_event_with_name_failure(self): start_state = State(name='start') busy_state = State(name='busy') do_work_event = Event(name='do_work', source_states=[busy_state], destination_state=busy_state) fsm = StateMachine(states=[start_state, busy_state], events=[do_work_event], initial_state=start_state) fsm.activate() assert fsm.can_fire_event_with_name('do_work') == False