diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_handlers.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_handlers.py b/tests/test_handlers.py index bf9dd9a0..00bb6f84 100644 --- a/tests/test_handlers.py +++ b/tests/test_handlers.py @@ -70,3 +70,30 @@ def test_handler_block(): for output in handler.input(input): names.append(output.name) assert names == ["cmd"] + + +def test_handler_interator(): + input = Input(".add 1 2") + + def add(input: Input): + yield Output( + "text", + str(sum(list(map(int, input.get_plain_text().lstrip(".add").split())))), + status=0, + block=False, + ) + yield Output("text", "ok", status=0, block=False) + + handler = Handler() + handler.handlers = [ + { + "priority": 1, + "router": StartswithRouter(".add"), + "handler": add, + }, + ] + + names = [] + for output in handler.input(input): + names.append(output.name) + assert names == ["3", "ok"] |
