diff --git a/argenta/app/entity.py b/argenta/app/entity.py index 94014e3..6cb9da2 100644 --- a/argenta/app/entity.py +++ b/argenta/app/entity.py @@ -149,9 +149,9 @@ class App: self._unknown_command_handler = handler - def set_empty_command_handler(self, handler: Callable[[str], None]) -> None: + def set_empty_command_handler(self, handler: Callable[[], None]) -> None: args = getfullargspec(handler).args - if len(args) != 1: + if len(args) != 0: raise IncorrectNumberOfHandlerArgsException() else: self._empty_input_command_handler = handler diff --git a/tests/system_tests/test_system_handling_non_standard_behavior.py b/tests/system_tests/test_system_handling_non_standard_behavior.py index 162a407..ff13599 100644 --- a/tests/system_tests/test_system_handling_non_standard_behavior.py +++ b/tests/system_tests/test_system_handling_non_standard_behavior.py @@ -24,6 +24,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}')) app.start_polling() output = mock_stdout.getvalue() @@ -42,6 +43,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App(ignore_command_register=False) app.include_router(router) + app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}')) app.start_polling() output = mock_stdout.getvalue() @@ -115,6 +117,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}')) app.start_polling() output = mock_stdout.getvalue() @@ -137,6 +140,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.get_trigger()}')) app.start_polling() output = mock_stdout.getvalue() @@ -155,6 +159,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_invalid_input_flags_handler(lambda command: print(f'Incorrect flag syntax: "{command}"')) app.start_polling() output = mock_stdout.getvalue() @@ -173,6 +178,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_empty_command_handler(lambda: print('Empty input command')) app.start_polling() output = mock_stdout.getvalue() @@ -191,6 +197,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase): app = App() app.include_router(router) + app.set_repeated_input_flags_handler(lambda command: print(f'Repeated input flags: "{command}"')) app.start_polling() output = mock_stdout.getvalue()