This commit is contained in:
2025-11-21 19:41:35 +03:00
parent 8edd59c1b8
commit 2e76f68d4a
37 changed files with 395 additions and 482 deletions
@@ -1,25 +1,21 @@
import io
import unittest
from contextlib import redirect_stdout
from argenta import App, Router, Command, Response
from argenta.command import InputCommand
class TestAppIntegration(unittest.TestCase):
def setUp(self) -> None:
self.app = App(override_system_messages=True, repeat_command_groups=False)
self.router = Router(title="App")
def test_simple_app() -> None:
app = App(override_system_messages=True, repeat_command_groups_printing=False)
router = Router(title="App")
@self.router.command(Command("HELP", description="Show help"))
def help_cmd(response: Response):
print("Available commands: HELP")
@router.command(Command("HELP", description="Show help"))
def help_cmd(response: Response):
print("Available commands: HELP")
_ = help_cmd # appease linter: function is registered via decorator
app.include_router(router)
self.app.include_router(self.router)
def test_help_command(self):
with redirect_stdout(io.StringIO()) as stdout:
self.router.finds_appropriate_handler(InputCommand.parse("HELP"))
self.assertIn("Available commands:", stdout.getvalue())
with redirect_stdout(io.StringIO()) as stdout:
router.finds_appropriate_handler(InputCommand.parse("HELP"))
assert "Available commands:" in stdout.getvalue()