Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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"]
Ejemplo n.º 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
Ejemplo n.º 5
0
 def test_call_with_state():
     action = StatefullAction(action_fct=lambda state: 10)
     action._state = {}
     with pytest.raises(ActionException):
         action({})