refactor tests

This commit is contained in:
2025-12-05 15:54:03 +03:00
parent b0e6127c1e
commit 20b638c421
9 changed files with 235 additions and 194 deletions
+4
View File
@@ -13,6 +13,10 @@ tests:
tests-cov: tests-cov:
python -m pytest --cov=argenta tests python -m pytest --cov=argenta tests
# Запустить тесты с отчетом о покрытии с html репортом
tests-cov-html:
python -m pytest --cov=argenta tests --cov-report=html
# Отформатировать код (Ruff + isort) # Отформатировать код (Ruff + isort)
format: format:
python -m ruff format ./src python -m ruff format ./src
+15 -2
View File
@@ -1,2 +1,15 @@
import sys from argenta import App, Router, Command, Response
print(sys.version_info >= (3, 13))
app = App(override_system_messages=True)
router = Router()
@router.command(Command('test', aliases={'alias', 'primer'}))
def handler(res: Response):
pass
@router.command(Command('test2', aliases={'alias', 'primer'}))
def handler2(res: Response):
pass
print(router.aliases)
+8
View File
@@ -50,6 +50,14 @@ line-length=90
[tool.pyright] [tool.pyright]
typeCheckingMode = "strict" typeCheckingMode = "strict"
[[tool.pyright.executionEnvironments]]
root = "tests/"
reportPrivateUsage = false
reportUnusedFunction = false
[tool.coverage.run]
branch = true
[tool.mypy] [tool.mypy]
disable_error_code = "import-untyped" disable_error_code = "import-untyped"
+1 -10
View File
@@ -323,7 +323,7 @@ class BaseApp:
for router_entity in self.registered_routers: for router_entity in self.registered_routers:
router_triggers = router_entity.triggers router_triggers = router_entity.triggers
router_aliases = router_entity.aliases router_aliases = router_entity.aliases
combined = router_triggers + router_aliases combined = router_triggers | router_aliases
for trigger in combined: for trigger in combined:
self._matching_default_triggers_with_routers[trigger] = router_entity self._matching_default_triggers_with_routers[trigger] = router_entity
@@ -331,15 +331,6 @@ class BaseApp:
self._autocompleter.initial_setup(list(self._current_matching_triggers_with_routers.keys())) self._autocompleter.initial_setup(list(self._current_matching_triggers_with_routers.keys()))
seen = {}
for item in list(self._current_matching_triggers_with_routers.keys()):
if item in seen:
Console().print(
f"\n[b red]WARNING:[/b red] Overlapping trigger or alias: [b blue]{item}[/b blue]"
)
else:
seen[item] = True
if not self._override_system_messages: if not self._override_system_messages:
self._setup_default_view() self._setup_default_view()
+3 -3
View File
@@ -17,7 +17,7 @@ ParseResult = tuple[str, InputFlags]
MIN_FLAG_PREFIX: str = "-" MIN_FLAG_PREFIX: str = "-"
PREFIX_TYPE = Literal["-", "--", "---"] PREFIX_TYPE = Literal["-", "--", "---"]
DEFAULT_WITHOUT_FLAGS: Flags = Flags() DEFAULT_WITHOUT_FLAGS: Flags = Flags()
DEFAULT_WITHOUT_ALIASES: list[Never] = [] DEFAULT_WITHOUT_ALIASES: set[Never] = set()
DEFAULT_WITHOUT_INPUT_FLAGS: InputFlags = InputFlags() DEFAULT_WITHOUT_INPUT_FLAGS: InputFlags = InputFlags()
@@ -29,7 +29,7 @@ class Command:
*, *,
description: str = "Some useful command", description: str = "Some useful command",
flags: Flag | Flags = DEFAULT_WITHOUT_FLAGS, flags: Flag | Flags = DEFAULT_WITHOUT_FLAGS,
aliases: list[str] | list[Never] = DEFAULT_WITHOUT_ALIASES, aliases: set[str] | set[Never] = DEFAULT_WITHOUT_ALIASES,
): ):
""" """
Public. The command that can and should be registered in the Router Public. The command that can and should be registered in the Router
@@ -41,7 +41,7 @@ class Command:
self.registered_flags: Flags = flags if isinstance(flags, Flags) else Flags([flags]) self.registered_flags: Flags = flags if isinstance(flags, Flags) else Flags([flags])
self.trigger: str = trigger self.trigger: str = trigger
self.description: str = description self.description: str = description
self.aliases: list[str] | list[Never] = aliases self.aliases: set[str] | set[Never] = aliases
def validate_input_flag(self, flag: InputFlag) -> ValidationStatus: def validate_input_flag(self, flag: InputFlag) -> ValidationStatus:
""" """
+24 -38
View File
@@ -42,6 +42,9 @@ class Router:
self.command_handlers: CommandHandlers = CommandHandlers() self.command_handlers: CommandHandlers = CommandHandlers()
self.command_register_ignore: bool = False self.command_register_ignore: bool = False
self.aliases: set[str] = set()
self.triggers: set[str] = set()
def command(self, command: Command | str) -> Callable[[HandlerFunc], HandlerFunc]: def command(self, command: Command | str) -> Callable[[HandlerFunc], HandlerFunc]:
""" """
Public. Registers handler Public. Registers handler
@@ -53,7 +56,13 @@ class Router:
else: else:
redefined_command = command redefined_command = command
_validate_command(redefined_command) self._validate_command(redefined_command)
if overlapping := (self.aliases | self.triggers) & command.aliases:
Console().print(f"\n[b red]WARNING:[/b red] Overlapping trigger or alias: [b blue]{overlapping}[/b blue]")
self.aliases.update(command.aliases)
self.triggers.add(command.trigger)
def decorator(func: HandlerFunc) -> HandlerFunc: def decorator(func: HandlerFunc) -> HandlerFunc:
_validate_func_args(func) _validate_func_args(func)
@@ -62,6 +71,20 @@ class Router:
return decorator return decorator
def _validate_command(self, command: Command) -> None:
"""
Private. Validates the command registered in handler
:param command: validated command
:return: None if command is valid else raise exception
"""
command_name: str = command.trigger
if command_name.find(" ") != -1:
raise TriggerContainSpacesException()
flags: Flags = command.registered_flags
flags_name: list[str] = [flag.string_entity.lower() for flag in flags]
if len(set(flags_name)) < len(flags_name):
raise RepeatedFlagNameException()
def finds_appropriate_handler(self, input_command: InputCommand) -> None: def finds_appropriate_handler(self, input_command: InputCommand) -> None:
""" """
Private. Finds the appropriate handler for given input command and passes control to it Private. Finds the appropriate handler for given input command and passes control to it
@@ -105,29 +128,6 @@ class Router:
response = Response(ResponseStatus.ALL_FLAGS_VALID) response = Response(ResponseStatus.ALL_FLAGS_VALID)
command_handler.handling(response) command_handler.handling(response)
@property
def triggers(self) -> list[str]:
"""
Public. Gets registered triggers
:return: registered in router triggers as list[str]
"""
all_triggers: list[str] = []
for command_handler in self.command_handlers:
all_triggers.append(command_handler.handled_command.trigger)
return all_triggers
@property
def aliases(self) -> list[str]:
"""
Public. Gets registered aliases
:return: registered in router aliases as list[str]
"""
all_aliases: list[str] = []
for command_handler in self.command_handlers:
if command_handler.handled_command.aliases:
all_aliases.extend(command_handler.handled_command.aliases)
return all_aliases
class CommandDecorator: class CommandDecorator:
def __init__(self, router_instance: Router, command: Command): def __init__(self, router_instance: Router, command: Command):
@@ -189,17 +189,3 @@ def _validate_func_args(func: Callable[..., None]) -> None:
highlight=False, highlight=False,
) )
def _validate_command(command: Command) -> None:
"""
Private. Validates the command registered in handler
:param command: validated command
:return: None if command is valid else raise exception
"""
command_name: str = command.trigger
if command_name.find(" ") != -1:
raise TriggerContainSpacesException()
flags: Flags = command.registered_flags
flags_name: list[str] = [flag.string_entity.lower() for flag in flags]
if len(set(flags_name)) < len(flags_name):
raise RepeatedFlagNameException()
+53 -30
View File
@@ -1,74 +1,97 @@
import unittest from pytest import CaptureFixture
from argenta.app import App from argenta.app import App
from argenta.response import Response
from argenta.command.models import Command, InputCommand from argenta.command.models import Command, InputCommand
from argenta.router import Router from argenta.router import Router
class MyTestCase(unittest.TestCase): def test_is_exit_command1():
def test_is_exit_command1(self):
app = App() app = App()
self.assertEqual(app._is_exit_command(InputCommand('q')), True) assert app._is_exit_command(InputCommand('q')) is True
def test_is_exit_command5(self):
def test_is_exit_command5():
app = App() app = App()
self.assertEqual(app._is_exit_command(InputCommand('Q')), True) assert app._is_exit_command(InputCommand('Q')) is True
def test_is_exit_command2(self):
def test_is_exit_command2():
app = App(ignore_command_register=False) app = App(ignore_command_register=False)
self.assertEqual(app._is_exit_command(InputCommand('q')), False) assert app._is_exit_command(InputCommand('q')) is False
def test_is_exit_command3(self):
def test_is_exit_command3():
app = App(exit_command=Command('quit')) app = App(exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('quit')), True) assert app._is_exit_command(InputCommand('quit')) is True
def test_is_exit_command4(self):
def test_is_exit_command4():
app = App(exit_command=Command('quit')) app = App(exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('qUIt')), True) assert app._is_exit_command(InputCommand('qUIt')) is True
def test_is_exit_command6(self):
def test_is_exit_command6():
app = App(ignore_command_register=False, app = App(ignore_command_register=False,
exit_command=Command('quit')) exit_command=Command('quit'))
self.assertEqual(app._is_exit_command(InputCommand('qUIt')), False) assert app._is_exit_command(InputCommand('qUIt')) is False
def test_is_unknown_command1(self):
def test_is_unknown_command1():
app = App() app = App()
app.set_unknown_command_handler(lambda command: None) app.set_unknown_command_handler(lambda command: None)
app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()} app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()}
self.assertEqual(app._is_unknown_command(InputCommand('fr')), False) assert app._is_unknown_command(InputCommand('fr')) is False
def test_is_unknown_command2(self):
def test_is_unknown_command2():
app = App() app = App()
app.set_unknown_command_handler(lambda command: None) app.set_unknown_command_handler(lambda command: None)
app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()} app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()}
self.assertEqual(app._is_unknown_command(InputCommand('cr')), True) assert app._is_unknown_command(InputCommand('cr')) is True
def test_is_unknown_command3(self): def test_is_unknown_command3():
app = App(ignore_command_register=False) app = App(ignore_command_register=False)
app.set_unknown_command_handler(lambda command: None) app.set_unknown_command_handler(lambda command: None)
app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()} app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()}
self.assertEqual(app._is_unknown_command(InputCommand('pr')), True) assert app._is_unknown_command(InputCommand('pr')) is True
def test_is_unknown_command4(self):
def test_is_unknown_command4():
app = App(ignore_command_register=False) app = App(ignore_command_register=False)
app.set_unknown_command_handler(lambda command: None) app.set_unknown_command_handler(lambda command: None)
app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()} app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()}
self.assertEqual(app._is_unknown_command(InputCommand('tW')), False) assert app._is_unknown_command(InputCommand('tW')) is False
def test_add_messages_on_startup():
app = App()
app.add_message_on_startup('Some message')
assert app._messages_on_startup == ['Some message']
def test_include_routers():
app = App()
router = Router()
router2 = Router()
app.include_routers(router, router2)
assert app.registered_routers.registered_routers == [router, router2]
def test_overlapping_aliases(capsys: CaptureFixture[str]):
app = App(override_system_messages=True)
router = Router()
@router.command(Command('test', aliases=['alias']))
def handler(res: Response):
pass
@router.command(Command('test2', aliases=['alias']))
def handler2(res: Response):
pass
app.include_routers(router)
app._pre_cycle_setup()
captured = capsys.readouterr()
assert "Overlapping" in captured.out
+27 -12
View File
@@ -1,21 +1,36 @@
import unittest
from argenta.app.dividing_line import DynamicDividingLine, StaticDividingLine from argenta.app.dividing_line import DynamicDividingLine, StaticDividingLine
class TestDividingLine(unittest.TestCase): def test_get_static_dividing_line_full_line():
def test_get_static_dividing_line_full_line(self):
line = StaticDividingLine('-') line = StaticDividingLine('-')
self.assertEqual(line.get_full_static_line(is_override=True).count('-'), 25) assert line.get_full_static_line(is_override=True).count('-') == 25
def test_get_dynamic_dividing_line_full_line(self): def test_get_static_dividing_line2_full_line():
line = DynamicDividingLine() line = StaticDividingLine('-', length=5)
self.assertEqual(line.get_full_dynamic_line(length=20, is_override=True).count('-'), 20) assert line.get_full_static_line(is_override=False) == '\n[dim]-----[/dim]\n'
def test_get_dividing_line_unit_part(self): def test_get_dividing_line_unit_part():
line = StaticDividingLine('') line = StaticDividingLine('')
self.assertEqual(line.get_unit_part(), ' ') assert line.get_unit_part() == ' '
def test_get_dividing_line2_unit_part(self): def test_get_dividing_line2_unit_part():
line = StaticDividingLine('+-0987654321!@#$%^&*()_') line = StaticDividingLine('+-0987654321!@#$%^&*()_')
self.assertEqual(line.get_unit_part(), '+') assert line.get_unit_part() == '+'
def test_get_dynamic_dividing_line_full_line():
line = DynamicDividingLine()
assert line.get_full_dynamic_line(length=20, is_override=True).count('-') == 20
def test_get_dynamic_dividing_line2_full_line():
line = DynamicDividingLine()
assert line.get_full_dynamic_line(length=5, is_override=False) == '\n[dim]-----[/dim]\n'
def test_get_dynamic_dividing_line_unit_part():
line = DynamicDividingLine('')
assert line.get_unit_part() == ' '
def test_get_dynamic_dividing_line2_unit_part():
line = DynamicDividingLine('45n352834528&^%@&*T$G')
assert line.get_unit_part() == '4'
+47 -46
View File
@@ -1,5 +1,5 @@
import re import re
import unittest import pytest
from argenta.command import Command from argenta.command import Command
from argenta.command.flag import Flag, InputFlag from argenta.command.flag import Flag, InputFlag
@@ -7,97 +7,98 @@ from argenta.command.flag.flags import Flags, InputFlags
from argenta.command.flag.models import PossibleValues, ValidationStatus from argenta.command.flag.models import PossibleValues, ValidationStatus
from argenta.response.entity import Response from argenta.response.entity import Response
from argenta.router import Router from argenta.router import Router
from argenta.router.entity import _structuring_input_flags, _validate_command, _validate_func_args # pyright: ignore[reportPrivateUsage] from argenta.router.entity import _structuring_input_flags, _validate_func_args # pyright: ignore[reportPrivateUsage]
from argenta.router.exceptions import (RepeatedFlagNameException, from argenta.router.exceptions import (RepeatedFlagNameException,
RequiredArgumentNotPassedException, RequiredArgumentNotPassedException,
TriggerContainSpacesException) TriggerContainSpacesException)
class TestRouter(unittest.TestCase): def test_register_command_with_spaces_in_trigger():
def test_register_command_with_spaces_in_trigger(self): router = Router()
with self.assertRaises(TriggerContainSpacesException): with pytest.raises(TriggerContainSpacesException):
_validate_command(Command(trigger='command with spaces')) router._validate_command(Command(trigger='command with spaces'))
def test_register_command_with_repeated_flags(self): def test_register_command_with_repeated_flags():
with self.assertRaises(RepeatedFlagNameException): router = Router()
_validate_command(Command(trigger='command', flags=Flags([Flag('test'), Flag('test')]))) with pytest.raises(RepeatedFlagNameException):
router._validate_command(Command(trigger='command', flags=Flags([Flag('test'), Flag('test')])))
def test_structuring_input_flags1(self): def test_structuring_input_flags1():
cmd = Command('cmd') cmd = Command('cmd')
input_flags = InputFlags([InputFlag('ssh', input_value=None, status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='', status=None)])
self.assertEqual(_structuring_input_flags(cmd, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value=None, status=ValidationStatus.UNDEFINED)])) assert _structuring_input_flags(cmd, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='', status=ValidationStatus.UNDEFINED)])
def test_structuring_input_flags2(self): def test_structuring_input_flags2():
cmd = Command('cmd') cmd = Command('cmd')
input_flags = InputFlags([InputFlag('ssh', input_value='some', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='some', status=None)])
self.assertEqual(_structuring_input_flags(cmd, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='some', status=ValidationStatus.UNDEFINED)])) assert _structuring_input_flags(cmd, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='some', status=ValidationStatus.UNDEFINED)])
def test_structuring_input_flags3(self): def test_structuring_input_flags3():
cmd = Command('cmd', flags=Flag('port')) cmd = Command('cmd', flags=Flag('port'))
input_flags = InputFlags([InputFlag('ssh', input_value='some2', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='some2', status=None)])
self.assertEqual(_structuring_input_flags(cmd, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='some2', status=ValidationStatus.UNDEFINED)])) assert _structuring_input_flags(cmd, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='some2', status=ValidationStatus.UNDEFINED)])
def test_structuring_input_flags4(self): def test_structuring_input_flags4():
command = Command('cmd', flags=Flag('ssh', possible_values=PossibleValues.NEITHER)) command = Command('cmd', flags=Flag('ssh', possible_values=PossibleValues.NEITHER))
input_flags = InputFlags([InputFlag('ssh', input_value='some3', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='some3', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='some3', status=ValidationStatus.INVALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='some3', status=ValidationStatus.INVALID)])
def test_structuring_input_flags5(self): def test_structuring_input_flags5():
command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'some[1-5]$'))) command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'some[1-5]$')))
input_flags = InputFlags([InputFlag('ssh', input_value='some40', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='some40', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='some40', status=ValidationStatus.INVALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='some40', status=ValidationStatus.INVALID)])
def test_structuring_input_flags6(self): def test_structuring_input_flags6():
command = Command('cmd', flags=Flag('ssh', possible_values=['example'])) command = Command('cmd', flags=Flag('ssh', possible_values=['example']))
input_flags = InputFlags([InputFlag('ssh', input_value='example2', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='example2', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='example2', status=ValidationStatus.INVALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='example2', status=ValidationStatus.INVALID)])
def test_structuring_input_flags7(self): def test_structuring_input_flags7():
command = Command('cmd', flags=Flag('port')) command = Command('cmd', flags=Flag('port'))
input_flags = InputFlags([InputFlag('port', input_value='some2', status=None)]) input_flags = InputFlags([InputFlag('port', input_value='some2', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('port', input_value='some2', status=ValidationStatus.VALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('port', input_value='some2', status=ValidationStatus.VALID)])
def test_structuring_input_flags8(self): def test_structuring_input_flags8():
command = Command('cmd', flags=Flag('port', possible_values=['some2', 'some3'])) command = Command('cmd', flags=Flag('port', possible_values=['some2', 'some3']))
input_flags = InputFlags([InputFlag('port', input_value='some2', status=None)]) input_flags = InputFlags([InputFlag('port', input_value='some2', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('port', input_value='some2', status=ValidationStatus.VALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('port', input_value='some2', status=ValidationStatus.VALID)])
def test_structuring_input_flags9(self): def test_structuring_input_flags9():
command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'more[1-5]$'))) command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'more[1-5]$')))
input_flags = InputFlags([InputFlag('ssh', input_value='more5', status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='more5', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value='more5', status=ValidationStatus.VALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='more5', status=ValidationStatus.VALID)])
def test_structuring_input_flags10(self): def test_structuring_input_flags10():
command = Command('cmd', flags=Flag('ssh', possible_values=PossibleValues.NEITHER)) command = Command('cmd', flags=Flag('ssh', possible_values=PossibleValues.NEITHER))
input_flags = InputFlags([InputFlag('ssh', input_value=None, status=None)]) input_flags = InputFlags([InputFlag('ssh', input_value='', status=None)])
self.assertEqual(_structuring_input_flags(command, input_flags).input_flags, InputFlags([InputFlag('ssh', input_value=None, status=ValidationStatus.VALID)])) assert _structuring_input_flags(command, input_flags).input_flags == InputFlags([InputFlag('ssh', input_value='', status=ValidationStatus.VALID)])
def test_validate_incorrect_func_args1(self): def test_validate_incorrect_func_args1():
def handler(): def handler():
pass pass
with self.assertRaises(RequiredArgumentNotPassedException): with pytest.raises(RequiredArgumentNotPassedException):
_validate_func_args(handler) # pyright: ignore[reportArgumentType] _validate_func_args(handler) # pyright: ignore[reportArgumentType]
def test_get_router_aliases(self): def test_get_router_aliases():
router = Router() router = Router()
@router.command(Command('some', aliases=['test', 'case'])) @router.command(Command('some', aliases={'test', 'case'}))
def handler(response: Response) -> None: # pyright: ignore[reportUnusedFunction] def handler(response: Response) -> None:
pass pass
self.assertListEqual(router.aliases, ['test', 'case']) assert router.aliases == {'test', 'case'}
def test_get_router_aliases2(self): def test_get_router_aliases2():
router = Router() router = Router()
@router.command(Command('some', aliases=['test', 'case'])) @router.command(Command('some', aliases={'test', 'case'}))
def handler(response: Response): # pyright: ignore[reportUnusedFunction] def handler(response: Response):
pass pass
@router.command(Command('ext', aliases=['more', 'foo'])) @router.command(Command('ext', aliases={'more', 'foo'}))
def handler2(response: Response): # pyright: ignore[reportUnusedFunction] def handler2(response: Response):
pass pass
self.assertListEqual(router.aliases, ['test', 'case', 'more', 'foo']) assert router.aliases == {'test', 'case', 'more', 'foo'}
def test_get_router_aliases3(self): def test_get_router_aliases3():
router = Router() router = Router()
@router.command(Command('some')) @router.command(Command('some'))
def handler(response: Response): # pyright: ignore[reportUnusedFunction] def handler(response: Response):
pass pass
self.assertListEqual(router.aliases, []) assert router.aliases == set()