Passed
Pull Request — master (#3)
by Guibert
49s
created

test_leaf.test_action_results()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
from curio import run
2
3
from libellule.control_flow.leaf import action, condition
4
5
6
def test_condition():
7
    async def target_test(value):
8
        return value
9
10
    assert run(
11
        condition(target_test, value=True)
12
    )  # pylint: disable=unexpected-keyword-arg
13
14
    assert not run(
15
        condition(target_test, value=False)
16
    )  # pylint: disable=unexpected-keyword-arg
17
18
19
def test_action_with_exception_is_falsy():
20
    async def generate_exception():
21
        raise Exception("Bing!")
22
23
    assert not run(action(generate_exception))
24
25
26
def test_action_results():
27
    async def compute(a, b):
28
        return a + b
29
30
    assert run(action(compute, a=1, b=1)) == 2
31