Update documentation

This commit is contained in:
2026-02-02 22:23:03 +03:00
parent 417e0e2905
commit fcff6f4263
27 changed files with 110 additions and 231 deletions
+5 -6
View File
@@ -8,22 +8,21 @@ from argenta import App, Orchestrator, Router, Command, Response
@pytest.fixture(autouse=True)
def patched_argv():
with patch.object(sys, 'argv', ['program.py']):
with patch.object(sys, "argv", ["program.py"]):
yield
def test_input_incorrect_command(capsys: CaptureFixture[str]):
router = Router()
orchestrator = Orchestrator()
@router.command(Command('test'))
@router.command(Command("test"))
def test(response: Response) -> None:
print('test command')
print("test command")
app = App(override_system_messages=True, printer=print)
app.include_router(router)
app.set_unknown_command_handler(
lambda command: print(f'Unknown command: {command.trigger}')
)
app.set_unknown_command_handler(lambda command: print(f"Unknown command: {command.trigger}"))
with patch("builtins.input", side_effect=["help", "q"]):
orchestrator.start_polling(app)
@@ -17,5 +17,5 @@ def test_simple_app() -> None:
with redirect_stdout(io.StringIO()) as stdout:
router.finds_appropriate_handler(InputCommand.parse("HELP"))
assert "Available commands:" in stdout.getvalue()
@@ -11,18 +11,20 @@ from argenta.di.integration import setup_dishka, FromDishka
class Service:
def hello(self) -> str:
return "world"
def get_service() -> Service:
return Service()
router = Router(title="DI")
@router.command("HELLO")
def hello(response: Response, service: FromDishka[Service]) -> None:
print(f"hello {service.hello()}")
class _FakeApp:
# Minimal stub for setup_dishka; app object is not used in unit tests
registered_routers = [router]
@@ -31,12 +33,12 @@ class _FakeApp:
def test_hello_uses_service():
provider = Provider(scope=Scope.APP)
provider.provide(get_service)
container = make_container(provider)
setup_dishka(app=_FakeApp(), container=container, auto_inject=True)
# Call handler
with redirect_stdout(io.StringIO()) as stdout:
router.finds_appropriate_handler(InputCommand.parse('HELLO'))
router.finds_appropriate_handler(InputCommand.parse("HELLO"))
assert "hello world" in stdout.getvalue()
@@ -7,6 +7,7 @@ from argenta.command import InputCommand
router = Router(title="Demo")
@router.command(Command("PING", description="Ping command"))
def ping(response: Response):
print("PONG")