Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
def ctx() -> Context:
    return Context.make()