mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
docs
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import io
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
from argenta import Router, Command, Response
|
||||
@@ -8,15 +7,13 @@ from argenta.command import InputCommand
|
||||
|
||||
router = Router(title="Demo")
|
||||
|
||||
|
||||
@router.command(Command("PING", description="Ping command"))
|
||||
def ping(response: Response):
|
||||
print("PONG")
|
||||
|
||||
|
||||
class TestSimpleHandler(unittest.TestCase):
|
||||
def test_ping_prints_pong(self):
|
||||
# Имитация запуска хендлера через роутер
|
||||
with redirect_stdout(io.StringIO()) as stdout:
|
||||
router.finds_appropriate_handler(InputCommand.parse("PING"))
|
||||
self.assertIn("PONG", stdout.getvalue())
|
||||
def test_ping_prints_pong():
|
||||
# Call handler
|
||||
with redirect_stdout(io.StringIO()) as stdout:
|
||||
router.finds_appropriate_handler(InputCommand.parse("PING"))
|
||||
assert "PONG" in stdout.getvalue()
|
||||
|
||||
Reference in New Issue
Block a user