Passed
Pull Request — master (#4)
by Guibert
50s
created

tests.test_leaf   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 17
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A test_condition() 0 10 1
A test_action_with_exception_is_falsy() 0 5 1
A test_action_results() 0 5 1
1
from async_btree import action, condition
2
3
4
def test_condition(kernel):
5
    async def target_test(value):
6
        return value
7
8
    assert kernel.run(
9
        condition(target_test, value=True)
10
    )  # pylint: disable=unexpected-keyword-arg
11
12
    assert not kernel.run(
13
        condition(target_test, value=False)
14
    )  # pylint: disable=unexpected-keyword-arg
15
16
17
def test_action_with_exception_is_falsy(kernel):
18
    async def generate_exception():
19
        raise Exception("Bing!")
20
21
    assert not kernel.run(action(generate_exception))
22
23
24
def test_action_results(kernel):
25
    async def compute(a, b):
26
        return a + b
27
28
    assert kernel.run(action(compute, a=1, b=1)) == 2
29