mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 10:05:28 +03:00
fix bugs
This commit is contained in:
@@ -8,10 +8,10 @@ from argenta.app import App
|
||||
|
||||
class TimeOfPreCycleSetup:
|
||||
@staticmethod
|
||||
def ten_thousands_commands_with_two_aliases():
|
||||
def commands_with_two_aliases(num_of_commands: int):
|
||||
router = Router()
|
||||
|
||||
for i in range(10000):
|
||||
for i in range(num_of_commands):
|
||||
@router.command(Command(f'cmd{i}', aliases=[f'cdr{i}', f'prt{i}']))
|
||||
def handler(response: Response):
|
||||
pass
|
||||
@@ -22,38 +22,10 @@ class TimeOfPreCycleSetup:
|
||||
return get_time_of_pre_cycle_setup(app)
|
||||
|
||||
@staticmethod
|
||||
def ten_thousands_commands_with_one_aliases():
|
||||
def commands_with_one_aliases(num_of_commands: int):
|
||||
router = Router()
|
||||
|
||||
for i in range(10000):
|
||||
@router.command(Command(f'cmd{i}', aliases=[f'prt{i}']))
|
||||
def handler(response: Response):
|
||||
pass
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
|
||||
return get_time_of_pre_cycle_setup(app)
|
||||
|
||||
@staticmethod
|
||||
def one_hundred_thousands_commands_with_two_aliases():
|
||||
router = Router()
|
||||
|
||||
for i in range(100000):
|
||||
@router.command(Command(f'cmd{i}', aliases=[f'cdr{i}', f'prt{i}']))
|
||||
def handler(response: Response):
|
||||
pass
|
||||
|
||||
app = App()
|
||||
app.include_router(router)
|
||||
|
||||
return get_time_of_pre_cycle_setup(app)
|
||||
|
||||
@staticmethod
|
||||
def one_hundred_thousands_commands_with_one_aliases():
|
||||
router = Router()
|
||||
|
||||
for i in range(100000):
|
||||
for i in range(num_of_commands):
|
||||
@router.command(Command(f'cmd{i}', aliases=[f'cdr{i}']))
|
||||
def handler(response: Response):
|
||||
pass
|
||||
|
||||
+16
-2
@@ -1,4 +1,18 @@
|
||||
from metrics_tests.get_time_of_pre_cycle_setup import TimeOfPreCycleSetup
|
||||
from argenta.app import App
|
||||
from argenta.command import Command
|
||||
from argenta.orchestrator import Orchestrator
|
||||
from argenta.router import Router
|
||||
|
||||
|
||||
print(TimeOfPreCycleSetup.one_hundred_thousands_commands_with_two_aliases())
|
||||
router = Router()
|
||||
orchestrator = Orchestrator()
|
||||
|
||||
@router.command(Command('test'))
|
||||
def test(response):
|
||||
print('test command')
|
||||
|
||||
app = App(ignore_command_register=True,
|
||||
override_system_messages=True,
|
||||
print_func=print)
|
||||
app.include_router(router)
|
||||
orchestrator.start_polling(app)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "argenta"
|
||||
version = "1.0.6"
|
||||
version = "1.0.7"
|
||||
description = "Python library for building modular CLI applications"
|
||||
authors = [{ name = "kolo", email = "kolo.is.main@gmail.com" }]
|
||||
requires-python = ">=3.8"
|
||||
|
||||
@@ -415,7 +415,7 @@ class App(BaseApp):
|
||||
self._print_framed_text(res)
|
||||
continue
|
||||
|
||||
processing_router = self._current_matching_triggers_with_routers[input_command.get_trigger()]
|
||||
processing_router = self._current_matching_triggers_with_routers[input_command.get_trigger().lower()]
|
||||
|
||||
if processing_router.disable_redirect_stdout:
|
||||
if isinstance(self._dividing_line, StaticDividingLine):
|
||||
|
||||
@@ -3,6 +3,8 @@ from argenta.app import App
|
||||
|
||||
import unittest
|
||||
|
||||
from argenta.router import Router
|
||||
|
||||
|
||||
class MyTestCase(unittest.TestCase):
|
||||
def test_is_exit_command1(self):
|
||||
@@ -33,25 +35,25 @@ class MyTestCase(unittest.TestCase):
|
||||
def test_is_unknown_command1(self):
|
||||
app = App()
|
||||
app.set_unknown_command_handler(lambda command: None)
|
||||
app._all_registered_triggers_in_lower_case = ['fr', 'tr', 'de']
|
||||
app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()}
|
||||
self.assertEqual(app._is_unknown_command(InputCommand('fr')), False)
|
||||
|
||||
def test_is_unknown_command2(self):
|
||||
app = App()
|
||||
app.set_unknown_command_handler(lambda command: None)
|
||||
app._all_registered_triggers_in_lower_case = ['fr', 'tr', 'de']
|
||||
app._current_matching_triggers_with_routers = {'fr': Router(), 'tr': Router(), 'de': Router()}
|
||||
self.assertEqual(app._is_unknown_command(InputCommand('cr')), True)
|
||||
|
||||
def test_is_unknown_command3(self):
|
||||
app = App(ignore_command_register=False)
|
||||
app.set_unknown_command_handler(lambda command: None)
|
||||
app._all_registered_triggers_in_default_case = ['Pr', 'tW', 'deQW']
|
||||
app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()}
|
||||
self.assertEqual(app._is_unknown_command(InputCommand('pr')), True)
|
||||
|
||||
def test_is_unknown_command4(self):
|
||||
app = App(ignore_command_register=False)
|
||||
app.set_unknown_command_handler(lambda command: None)
|
||||
app._all_registered_triggers_in_default_case = ['Pr', 'tW', 'deQW']
|
||||
app._current_matching_triggers_with_routers = {'Pr': Router(), 'tW': Router(), 'deQW': Router()}
|
||||
self.assertEqual(app._is_unknown_command(InputCommand('tW')), False)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user