refactor system tests

This commit is contained in:
2025-12-06 20:01:47 +03:00
parent 1d2ab6f6bb
commit dee328525d
7 changed files with 427 additions and 425 deletions
-1
View File
@@ -1,5 +1,4 @@
import re
from sys import flags
from argenta.command.flag import Flag, InputFlag, PossibleValues
from argenta.command.flag.flags import Flags, InputFlags
+20 -24
View File
@@ -1,5 +1,6 @@
import re
import pytest
from pytest import CaptureFixture
from argenta.command import Command, InputCommand
from argenta.command.flag import Flag, InputFlag
@@ -89,64 +90,59 @@ def test_get_router_aliases():
def test_get_router_aliases2():
router = Router()
@router.command(Command('some', aliases={'test', 'case'}))
def handler(response: Response):
def handler(response: Response):
pass
@router.command(Command('ext', aliases={'more', 'foo'}))
def handler2(response: Response):
def handler2(response: Response):
pass
assert router.aliases == {'test', 'case', 'more', 'foo'}
def test_get_router_aliases3():
router = Router()
@router.command(Command('some'))
def handler(response: Response):
def handler(response: Response):
pass
assert router.aliases == set()
def test_find_appropiate_handler(capsys: pytest.CaptureFixture[str]):
router = Router()
@router.command(Command('hello', aliases={'hi'}))
def handler(res: Response):
print("Hello World!")
router.finds_appropriate_handler(InputCommand('hi'))
output = capsys.readouterr()
assert "Hello World!" in output.out
def test_find_appropiate_handler2(capsys: CaptureFixture[str]):
router = Router()
@router.command(Command('hello', flags=Flag('flag'), aliases={'hi'}))
def handler(res: Response):
print("Hello World!")
router.finds_appropriate_handler(InputCommand('hi'))
output = capsys.readouterr()
assert "Hello World!" in output.out
def test_wrong_typehint(capsys: pytest.CaptureFixture[str]):
class NotResponse: pass
def func(response: NotResponse): pass
_validate_func_args(func)
output = capsys.readouterr()
assert "WARNING" in output.out
def test_missing_typehint(capsys: pytest.CaptureFixture[str]):
def func(response): pass # pyright: ignore[reportMissingParameterType, reportUnknownParameterType]
_validate_func_args(func) # pyright: ignore[reportUnknownArgumentType]
output = capsys.readouterr()
assert output.out == ''