Example #1
0
 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
Example #2
0
 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
Example #3
0
 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"]
Example #4
0
 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
Example #5
0
 def test_call_with_state():
     action = StatefullAction(action_fct=lambda state: 10)
     action._state = {}
     with pytest.raises(ActionException):
         action({})