diff --git a/mock/mock_app/handlers/routers.py b/mock/mock_app/handlers/routers.py index 6bfebcd..a934e95 100644 --- a/mock/mock_app/handlers/routers.py +++ b/mock/mock_app/handlers/routers.py @@ -4,7 +4,7 @@ from rich.console import Console from argenta.command import Command from argenta.command.flag import Flag, FlagsGroup -from argenta.command.flag.defaults import host_flag, port_flag +from argenta.command.flag.defaults import DefaultFlags from argenta.router import Router from .handlers_implementation.help_command import help_command @@ -23,7 +23,7 @@ def command_help(): help_command() -@work_router.command(Command(trigger='P', description='Start Solving', flags=FlagsGroup(host_flag, port_flag))) +@work_router.command(Command(trigger='P', description='Start Solving', flags=FlagsGroup(DefaultFlags.host_flag, DefaultFlags.port_flag))) def command_start_solving(args: dict): print('Solving...') pprint(args) diff --git a/pyproject.toml b/pyproject.toml index 7fec07e..4195168 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "argenta" -version = "0.3.9" +version = "0.4.0" description = "python library for creating custom shells" authors = [ {name = "kolo", email = "kolo.is.main@gmail.com"} 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 0fd5de5..7d5e90a 100644 --- a/tests/system_tests/test_system_handling_non_standard_behavior.py +++ b/tests/system_tests/test_system_handling_non_standard_behavior.py @@ -159,4 +159,40 @@ class TestSystemHandlerNormalWork(unittest.TestCase): output = mock_stdout.getvalue() - self.assertIn("Incorrect flag syntax: \"test 535 --port\"", output) + self.assertIn("\nIncorrect flag syntax: \"test 535 --port\"\n", output) + + + @patch("builtins.input", side_effect=["", "q"]) + @patch("sys.stdout", new_callable=io.StringIO) + def test_input_empty_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock): + router = Router() + + @router.command(Command('test')) + def test(): + print(f'test command') + + app = App() + app.include_router(router) + app.start_polling() + + output = mock_stdout.getvalue() + + self.assertIn("\nEmpty input command\n", output) + + + @patch("builtins.input", side_effect=["test --port 22 --port 33", "q"]) + @patch("sys.stdout", new_callable=io.StringIO) + def test_input_correct_command_with_repeated_flags(self, mock_stdout: _io.StringIO, magick_mock: MagicMock): + router = Router() + + @router.command(Command('test', flags=DefaultFlags.port_flag)) + def test(args): + print('test command') + + app = App() + app.include_router(router) + app.start_polling() + + output = mock_stdout.getvalue() + + self.assertIn("\nRepeated input flags: \"test --port 22 --port 33\"", output)