def test_can_roll_back_function(): ctx = Context.make({"n": 4}) organizer = Organizer([add_two, add_three, fail_context]) result_ctx = organizer.run(ctx) assert ctx.is_failure assert result_ctx["result"] == 7
def test_can_run_functions(): ctx = Context.make({"n": 4}) organizer = Organizer([add_two, add_three]) result_ctx = organizer.run(ctx) assert ctx.is_success assert result_ctx["result"] == 9
def test_can_run_functions_with_failure(): ctx = Context.make({"n": 4}) organizer = Organizer([add_two, fail_context, add_three]) result_ctx = organizer.run(ctx) assert ctx.is_failure assert result_ctx["result"] == 6
def ctx() -> Context: return Context.make()