This commit is contained in:
2025-03-15 20:50:44 +03:00
parent beafdd0afd
commit 956febc757
3 changed files with 40 additions and 4 deletions
+2 -2
View File
@@ -4,7 +4,7 @@ from rich.console import Console
from argenta.command import Command from argenta.command import Command
from argenta.command.flag import Flag, FlagsGroup 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 argenta.router import Router
from .handlers_implementation.help_command import help_command from .handlers_implementation.help_command import help_command
@@ -23,7 +23,7 @@ def command_help():
help_command() 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): def command_start_solving(args: dict):
print('Solving...') print('Solving...')
pprint(args) pprint(args)
+1 -1
View File
@@ -1,6 +1,6 @@
[project] [project]
name = "argenta" name = "argenta"
version = "0.3.9" version = "0.4.0"
description = "python library for creating custom shells" description = "python library for creating custom shells"
authors = [ authors = [
{name = "kolo", email = "kolo.is.main@gmail.com"} {name = "kolo", email = "kolo.is.main@gmail.com"}
@@ -159,4 +159,40 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
output = mock_stdout.getvalue() 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)