Exemplo n.º 1
0
def test_two_steps(capsys):
    op = Operation(step(hello), step(world))
    result = op()

    out, _ = capsys.readouterr()
    assert out == "hello\nworld\n"
    
    assert result.success
Exemplo n.º 2
0
def test_step_function_args():
    def func(options, params, dep):
        assert options["params"] == params
        assert options["dep"] == dep
        
    op = Operation(step(func))
    op({"happy": "yes"}, dep=5)
Exemplo n.º 3
0
def test_one_step(capsys):
    
    create = Operation(step(hello))
    result = create()

    out, _ = capsys.readouterr()
    assert out == "hello\n"
    
    assert result.success
Exemplo n.º 4
0
def test_with_failure_handler():
    op = Operation(step(how_are_you), success(enjoy_your_day), failure(tell_joke))
    res = op({"happy": "I am sad"})
    assert res.failure
    assert "joke" in res
    assert res["joke"] == JOKE
Exemplo n.º 5
0
def test_input_failure():
    op = Operation(step(how_are_you), success(enjoy_your_day))
    res = op({"happy": "I am sad"})
    assert res.failure
Exemplo n.º 6
0
def test_input_success(capsys):
    op = Operation(step(how_are_you), success(enjoy_your_day))
    res = op({"happy": "yes"})
    out, _ = capsys.readouterr()
    assert out == ENJOY_MSG + "\n"
    assert res.success
Exemplo n.º 7
0
def test_fail_step():
    op = Operation(step(fail))
    res = op()
    assert res.failure
Exemplo n.º 8
0
def test_fail_fast():
    def must_not_be_called(options, **k):
        raise AssertionError("this step must not be called after fail fast!")
    
    op = Operation(step(fail, fail_fast=True), failure(must_not_be_called))
    op()