def test_simulate(monkeypatch): monkeypatch.setattr(InfoStreamer, "send_info", MagicMock()) action = StatefullAction() action._state = ReferencesDict() state = {"a": 10} action.simulate("action", state) assert dict(action.state) == state
def test__checks_state_items_for_rollback_failure_missing(): action = StatefullAction() action.rollback_action(["input"], lambda state: 10) action._state = {} with pytest.raises(ActionException): with action._checks_state_items_for_rollback(): pass
def test__checks_state_items_for_rollback_failure_exception(): action = StatefullAction() action.rollback_action(["input"], lambda state: 10) action._state = {} try: with action._checks_state_items_for_rollback(): raise Exception() except Exception: pass assert action._state["action_failed"]
def test__checks_state_items_for_rollback(): action = StatefullAction() action.rollback_action(["input"], lambda state: 10) action._state = {} with action._checks_state_items_for_rollback(): action._state["input"] = 10
def test_call_with_state(): action = StatefullAction(action_fct=lambda state: 10) action._state = {} with pytest.raises(ActionException): action({})