aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/test_injector.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_injector.py')
-rw-r--r--tests/test_injector.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test_injector.py b/tests/test_injector.py
index 426e5684..ccd040ba 100644
--- a/tests/test_injector.py
+++ b/tests/test_injector.py
@@ -1,4 +1,9 @@
+from infini.handler import Handler
from infini.injector import Injector
+from infini.input import Input
+from infini.loader import Loader
+from infini.output import Output
+from infini.router import Startswith
def test_injector():
@@ -12,3 +17,30 @@ def test_injector():
injector.parameters = {"a": 12, "b": 20, "c": 0, "card_name": name}
assert injector.inject(add)() == 32
assert injector.output(add) == 32
+
+
+def test_handler_injector():
+ input = Input("test_message")
+
+ def absolute(input: Input, plain_text: str) -> Output:
+ return input.output(
+ "text",
+ plain_text,
+ status=0,
+ block=False,
+ )
+
+ handler = Handler()
+ handler.handlers = [
+ {
+ "priority": 2,
+ "router": Startswith(".add"),
+ "handler": absolute,
+ },
+ ]
+
+ core = Loader().into_core()
+ core.handler = handler
+
+ for output in core.input(input):
+ assert output == "test_message"