Total Complexity | 3 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |