argenta 1.0.0a0__tar.gz → 1.0.0a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {argenta-1.0.0a0 → argenta-1.0.0a1}/PKG-INFO +1 -1
  2. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/default_mock_app/main.py +0 -1
  3. argenta-1.0.0a1/mock/local_test.py +13 -0
  4. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/handlers/routers.py +0 -3
  5. {argenta-1.0.0a0 → argenta-1.0.0a1}/pyproject.toml +33 -33
  6. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/flag/defaults.py +5 -5
  7. argenta-1.0.0a1/src/argenta/router/__init__.py +4 -0
  8. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/router/entity.py +2 -7
  9. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/router/exceptions.py +1 -9
  10. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/system_tests/test_system_handling_normal_behavior.py +3 -3
  11. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/unit_tests/test_command.py +10 -1
  12. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/unit_tests/test_flag.py +39 -1
  13. argenta-1.0.0a1/tests/unit_tests/test_router.py +144 -0
  14. argenta-1.0.0a0/mock/local_test.py +0 -15
  15. argenta-1.0.0a0/src/argenta/router/__init__.py +0 -4
  16. argenta-1.0.0a0/tests/unit_tests/test_flagsgroup.py +0 -26
  17. argenta-1.0.0a0/tests/unit_tests/test_router.py +0 -33
  18. {argenta-1.0.0a0 → argenta-1.0.0a1}/.github/workflows/ruff.yml +0 -0
  19. {argenta-1.0.0a0 → argenta-1.0.0a1}/.github/workflows/tests.yml +0 -0
  20. {argenta-1.0.0a0 → argenta-1.0.0a1}/.gitignore +0 -0
  21. {argenta-1.0.0a0 → argenta-1.0.0a1}/LICENSE +0 -0
  22. {argenta-1.0.0a0 → argenta-1.0.0a1}/README.md +0 -0
  23. {argenta-1.0.0a0 → argenta-1.0.0a1}/imgs/mock_app_preview1.png +0 -0
  24. {argenta-1.0.0a0 → argenta-1.0.0a1}/imgs/mock_app_preview2.png +0 -0
  25. {argenta-1.0.0a0 → argenta-1.0.0a1}/imgs/mock_app_preview3.png +0 -0
  26. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/__init__.py +0 -0
  27. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/default_mock_app/__init__.py +0 -0
  28. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/__init__.py +0 -0
  29. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/handlers/__init__.py +0 -0
  30. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/handlers/handlers_implementation/__init__.py +0 -0
  31. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/handlers/handlers_implementation/help_command.py +0 -0
  32. {argenta-1.0.0a0 → argenta-1.0.0a1}/mock/mock_app/main.py +0 -0
  33. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/__init__.py +0 -0
  34. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/__init__.py +0 -0
  35. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/__init__.py +0 -0
  36. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/autocompleter/__init__.py +0 -0
  37. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/autocompleter/entity.py +0 -0
  38. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/defaults.py +0 -0
  39. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/dividing_line/__init__.py +0 -0
  40. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/dividing_line/models.py +0 -0
  41. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/exceptions.py +0 -0
  42. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/models.py +0 -0
  43. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/registered_routers/__init__.py +0 -0
  44. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/app/registered_routers/entity.py +0 -0
  45. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/__init__.py +0 -0
  46. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/exceptions.py +0 -0
  47. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/flag/__init__.py +0 -0
  48. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/flag/models.py +0 -0
  49. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/command/models.py +0 -0
  50. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/__init__.py +0 -0
  51. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/argparser/__init__.py +0 -0
  52. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/argparser/arguments/__init__.py +0 -0
  53. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/argparser/arguments/models.py +0 -0
  54. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/argparser/entity.py +0 -0
  55. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/orchestrator/entity.py +0 -0
  56. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/router/command_handler/__init__.py +0 -0
  57. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/router/command_handler/entity.py +0 -0
  58. {argenta-1.0.0a0 → argenta-1.0.0a1}/src/argenta/router/defaults.py +0 -0
  59. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/__init__.py +0 -0
  60. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/system_tests/__init__.py +0 -0
  61. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/system_tests/test_system_handling_non_standard_behavior.py +0 -0
  62. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/unit_tests/__init__.py +0 -0
  63. {argenta-1.0.0a0 → argenta-1.0.0a1}/tests/unit_tests/test_dividing_line.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: argenta
3
- Version: 1.0.0a0
3
+ Version: 1.0.0a1
4
4
  Summary: Python library for creating TUI
5
5
  Author-email: kolo <kolo.is.main@gmail.com>
6
6
  License: MIT
@@ -1,5 +1,4 @@
1
1
  from argenta.app import App
2
- from argenta.app.defaults import PredefinedMessages
3
2
  from argenta.orchestrator import Orchestrator
4
3
 
5
4
  app = App(repeat_command_groups=True)
@@ -0,0 +1,13 @@
1
+ from argenta.command.flag.defaults import PredefinedFlags
2
+
3
+ router = Router()
4
+ flag = PredefinedFlags.SHORT_HELP
5
+
6
+ @router.command(Command('test', flags=flag))
7
+ def test(args: InputFlags):
8
+ print(f'help for {args.get_flag('h').get_name()} flag')
9
+
10
+ app = App(override_system_messages=True,
11
+ print_func=print)
12
+ app.include_router(router)
13
+ app.run_polling()
@@ -1,10 +1,7 @@
1
1
  from rich.console import Console
2
2
 
3
3
  from argenta.command import Command
4
- from argenta.command.flag import Flags, InputFlags
5
- from argenta.command.flag.defaults import PredefinedFlags
6
4
  from argenta.router import Router
7
- from .handlers_implementation.help_command import help_command
8
5
 
9
6
 
10
7
  work_router: Router = Router(title='Work points:')
@@ -1,33 +1,33 @@
1
- [project]
2
- name = "argenta"
3
- version = "1.0.0-alpha"
4
- description = "Python library for creating TUI"
5
- authors = [{ name = "kolo", email = "kolo.is.main@gmail.com" }]
6
- requires-python = ">=3.11, <4.0"
7
- readme = "README.md"
8
- license = { text = "MIT" }
9
- dependencies = [
10
- "rich (>=14.0.0,<15.0.0)",
11
- "art (>=6.4,<7.0)",
12
- "pyreadline3 (>=3.5.4,<4.0.0)",
13
- ]
14
-
15
- [dependency-groups]
16
- dev = [
17
- "pydoc-markdown>=4.8.2,<5",
18
- ]
19
-
20
- [tool.ruff]
21
- exclude = [
22
- ".idea",
23
- "venv",
24
- ".git",
25
- "poetry.lock",
26
- ".__pycache__",
27
- "tests"
28
- ]
29
-
30
- [build-system]
31
- requires = ["hatchling"]
32
- build-backend = "hatchling.build"
33
-
1
+ [project]
2
+ name = "argenta"
3
+ version = "1.0.0-alpha1"
4
+ description = "Python library for creating TUI"
5
+ authors = [{ name = "kolo", email = "kolo.is.main@gmail.com" }]
6
+ requires-python = ">=3.11, <4.0"
7
+ readme = "README.md"
8
+ license = { text = "MIT" }
9
+ dependencies = [
10
+ "rich (>=14.0.0,<15.0.0)",
11
+ "art (>=6.4,<7.0)",
12
+ "pyreadline3 (>=3.5.4,<4.0.0)",
13
+ ]
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "pydoc-markdown>=4.8.2,<5",
18
+ ]
19
+
20
+ [tool.ruff]
21
+ exclude = [
22
+ ".idea",
23
+ "venv",
24
+ ".git",
25
+ "poetry.lock",
26
+ ".__pycache__",
27
+ "tests"
28
+ ]
29
+
30
+ [build-system]
31
+ requires = ["hatchling"]
32
+ build-backend = "hatchling.build"
33
+
@@ -9,16 +9,16 @@ class PredefinedFlags:
9
9
  Public. A dataclass with predefined flags and most frequently used flags for quick use
10
10
  """
11
11
  HELP = Flag(name='help', possible_values=False)
12
- SHORT_HELP = Flag(name='h', prefix='-', possible_values=False)
12
+ SHORT_HELP = Flag(name='H', prefix='-', possible_values=False)
13
13
 
14
14
  INFO = Flag(name='info', possible_values=False)
15
- SHORT_INFO = Flag(name='i', prefix='-', possible_values=False)
15
+ SHORT_INFO = Flag(name='I', prefix='-', possible_values=False)
16
16
 
17
17
  ALL = Flag(name='all', possible_values=False)
18
- SHORT_ALL = Flag(name='a', prefix='-', possible_values=False)
18
+ SHORT_ALL = Flag(name='A', prefix='-', possible_values=False)
19
19
 
20
20
  HOST = Flag(name='host', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
21
- SHORT_HOST = Flag(name='h', prefix='-', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
21
+ SHORT_HOST = Flag(name='H', prefix='-', possible_values=re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$'))
22
22
 
23
23
  PORT = Flag(name='port', possible_values=re.compile(r'^\d{1,5}$'))
24
- SHORT_PORT = Flag(name='p', prefix='-', possible_values=re.compile(r'^\d{1,5}$'))
24
+ SHORT_PORT = Flag(name='P', prefix='-', possible_values=re.compile(r'^\d{1,5}$'))
@@ -0,0 +1,4 @@
1
+ __all__ = ["Router"]
2
+
3
+
4
+ from src.argenta.router.entity import Router
@@ -7,7 +7,6 @@ from src.argenta.command.flag.models import Flag, Flags, InputFlags
7
7
  from src.argenta.router.exceptions import (RepeatedFlagNameException,
8
8
  TooManyTransferredArgsException,
9
9
  RequiredArgumentNotPassedException,
10
- IncorrectNumberOfHandlerArgsException,
11
10
  TriggerContainSpacesException)
12
11
 
13
12
 
@@ -45,17 +44,13 @@ class Router:
45
44
  return command_decorator
46
45
 
47
46
 
48
- def set_invalid_input_flag_handler(self, func) -> None:
47
+ def set_invalid_input_flag_handler(self, func: Callable[[Flag], None]) -> None:
49
48
  """
50
49
  Public. Registers handler for invalid input flag
51
50
  :param func: registered handler
52
51
  :return: None
53
52
  """
54
- processed_args = getfullargspec(func).args
55
- if len(processed_args) != 1:
56
- raise IncorrectNumberOfHandlerArgsException()
57
- else:
58
- self._not_valid_flag_handler = func
53
+ self._not_valid_flag_handler = func
59
54
 
60
55
 
61
56
  def finds_appropriate_handler(self, input_command: InputCommand) -> None:
@@ -3,7 +3,7 @@ class RepeatedFlagNameException(Exception):
3
3
  Private. Raised when a repeated flag name is registered
4
4
  """
5
5
  def __str__(self):
6
- return "Repeated registered_flag name in register command"
6
+ return "Repeated registered flag names in register command"
7
7
 
8
8
 
9
9
  class TooManyTransferredArgsException(Exception):
@@ -22,14 +22,6 @@ class RequiredArgumentNotPassedException(Exception):
22
22
  return "Required argument not passed"
23
23
 
24
24
 
25
- class IncorrectNumberOfHandlerArgsException(Exception):
26
- """
27
- Private. Raised when incorrect number of arguments are passed
28
- """
29
- def __str__(self):
30
- return "Handler has incorrect number of arguments"
31
-
32
-
33
25
  class TriggerContainSpacesException(Exception):
34
26
  """
35
27
  Private. Raised when there is a space in the trigger being registered
@@ -91,7 +91,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
91
91
  self.assertIn('\nflag value for port flag : 22\n', output)
92
92
 
93
93
 
94
- @patch("builtins.input", side_effect=["test -h", "q"])
94
+ @patch("builtins.input", side_effect=["test -H", "q"])
95
95
  @patch("sys.stdout", new_callable=io.StringIO)
96
96
  def test_input_correct_command_with_default_flag(self, mock_stdout: _io.StringIO, magick_mock: MagicMock):
97
97
  router = Router()
@@ -99,7 +99,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
99
99
 
100
100
  @router.command(Command('test', flags=flag))
101
101
  def test(args: InputFlags):
102
- print(f'help for {args.get_flag('h').get_name()} flag')
102
+ print(f'help for {args.get_flag('H').get_name()} flag')
103
103
 
104
104
  app = App(override_system_messages=True,
105
105
  print_func=print)
@@ -108,7 +108,7 @@ class TestSystemHandlerNormalWork(unittest.TestCase):
108
108
 
109
109
  output = mock_stdout.getvalue()
110
110
 
111
- self.assertIn('\nhelp for h flag\n', output)
111
+ self.assertIn('\nhelp for H flag\n', output)
112
112
 
113
113
 
114
114
  @patch("builtins.input", side_effect=["test --info", "q"])
@@ -1,4 +1,5 @@
1
- from argenta.command.models import InputCommand
1
+ from argenta.command.flag import Flag, InputFlag, Flags
2
+ from argenta.command.models import InputCommand, Command
2
3
  from argenta.command.exceptions import (UnprocessedInputFlagException,
3
4
  RepeatedInputFlagsException,
4
5
  EmptyInputCommandException)
@@ -22,3 +23,11 @@ class TestInputCommand(unittest.TestCase):
22
23
  with self.assertRaises(EmptyInputCommandException):
23
24
  InputCommand.parse('')
24
25
 
26
+ def test_validate_correct_input_flag1(self):
27
+ command = Command('some', flags=Flag('test'))
28
+ self.assertEqual(command.validate_input_flag(InputFlag('test')), True)
29
+
30
+ def test_validate_correct_input_flag2(self):
31
+ command = Command('some', flags=Flags(Flag('test'), Flag('more')))
32
+ self.assertEqual(command.validate_input_flag(InputFlag('more')), True)
33
+
@@ -1,4 +1,4 @@
1
- from argenta.command.flag.models import Flag, InputFlag
1
+ from argenta.command.flag.models import Flag, InputFlag, InputFlags, Flags
2
2
 
3
3
  import unittest
4
4
  import re
@@ -68,6 +68,44 @@ class TestFlag(unittest.TestCase):
68
68
  flag = Flag(name='test', possible_values=True)
69
69
  self.assertEqual(flag.validate_input_flag_value('random value'), True)
70
70
 
71
+ def test_get_input_flag1(self):
72
+ flag = InputFlag(name='test')
73
+ input_flags = InputFlags(flag)
74
+ self.assertEqual(input_flags.get_flag('test'), flag)
75
+
76
+ def test_get_input_flag2(self):
77
+ flag = InputFlag(name='test')
78
+ flag2 = InputFlag(name='some')
79
+ input_flags = InputFlags(flag, flag2)
80
+ self.assertEqual(input_flags.get_flag('some'), flag2)
81
+
82
+ def test_get_undefined_input_flag(self):
83
+ flag = InputFlag(name='test')
84
+ flag2 = InputFlag(name='some')
85
+ input_flags = InputFlags(flag, flag2)
86
+ self.assertEqual(input_flags.get_flag('case'), None)
87
+
88
+ def test_get_flags(self):
89
+ flags = Flags()
90
+ list_of_flags = [
91
+ Flag('test1'),
92
+ Flag('test2'),
93
+ Flag('test3'),
94
+ ]
95
+ flags.add_flags(list_of_flags)
96
+ self.assertEqual(flags.get_flags(),
97
+ list_of_flags)
98
+
99
+ def test_add_flag(self):
100
+ flags = Flags()
101
+ flags.add_flag(Flag('test'))
102
+ self.assertEqual(len(flags.get_flags()), 1)
103
+
104
+ def test_add_flags(self):
105
+ flags = Flags()
106
+ flags.add_flags([Flag('test'), Flag('test2')])
107
+ self.assertEqual(len(flags.get_flags()), 2)
108
+
71
109
 
72
110
 
73
111
 
@@ -0,0 +1,144 @@
1
+ from argenta.command.flag import InputFlags, InputFlag, Flag, Flags
2
+ from src.argenta.router import Router
3
+ from src.argenta.command import Command
4
+ from src.argenta.router.exceptions import (TriggerContainSpacesException,
5
+ RepeatedFlagNameException,
6
+ TooManyTransferredArgsException,
7
+ RequiredArgumentNotPassedException)
8
+
9
+ import unittest
10
+ import re
11
+
12
+
13
+ class TestRouter(unittest.TestCase):
14
+ def test_get_router_title(self):
15
+ self.assertEqual(Router(title='test title').get_title(), 'test title')
16
+
17
+ def test_register_command_with_spaces_in_trigger(self):
18
+ router = Router()
19
+ with self.assertRaises(TriggerContainSpacesException):
20
+ router._validate_command(Command(trigger='command with spaces'))
21
+
22
+ def test_register_command_with_repeated_flags(self):
23
+ router = Router()
24
+ with self.assertRaises(RepeatedFlagNameException):
25
+ router._validate_command(Command(trigger='command', flags=Flags(Flag('test'), Flag('test'))))
26
+
27
+ def test_validate_incorrect_input_flag1(self):
28
+ router = Router()
29
+ router.set_invalid_input_flag_handler(lambda flag: None)
30
+ self.assertEqual(router._validate_input_flags(Command('cmd'), InputFlags(InputFlag('ssh'))), False)
31
+
32
+ def test_validate_incorrect_input_flag2(self):
33
+ router = Router()
34
+ router.set_invalid_input_flag_handler(lambda flag: None)
35
+ self.assertEqual(router._validate_input_flags(Command('cmd'), InputFlags(InputFlag('ssh', value='some'))), False)
36
+
37
+ def test_validate_incorrect_input_flag3(self):
38
+ router = Router()
39
+ router.set_invalid_input_flag_handler(lambda flag: None)
40
+ command = Command('cmd', flags=Flag('port'))
41
+ input_flags = InputFlags(InputFlag('ssh', value='some2'))
42
+ self.assertEqual(router._validate_input_flags(command, input_flags), False)
43
+
44
+ def test_validate_incorrect_input_flag4(self):
45
+ router = Router()
46
+ router.set_invalid_input_flag_handler(lambda flag: None)
47
+ command = Command('cmd', flags=Flag('ssh', possible_values=False))
48
+ input_flags = InputFlags(InputFlag('ssh', value='some3'))
49
+ self.assertEqual(router._validate_input_flags(command, input_flags), False)
50
+
51
+ def test_validate_incorrect_input_flag5(self):
52
+ router = Router()
53
+ router.set_invalid_input_flag_handler(lambda flag: None)
54
+ command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'some[1-5]$')))
55
+ input_flags = InputFlags(InputFlag('ssh', value='some40'))
56
+ self.assertEqual(router._validate_input_flags(command, input_flags), False)
57
+
58
+ def test_validate_incorrect_input_flag6(self):
59
+ router = Router()
60
+ router.set_invalid_input_flag_handler(lambda flag: None)
61
+ command = Command('cmd', flags=Flag('ssh', possible_values=['example']))
62
+ input_flags = InputFlags(InputFlag('ssh', value='example2'))
63
+ self.assertEqual(router._validate_input_flags(command, input_flags), False)
64
+
65
+ def test_validate_incorrect_input_flag7(self):
66
+ router = Router()
67
+ router.set_invalid_input_flag_handler(lambda flag: None)
68
+ command = Command('cmd', flags=Flag('ssh', possible_values=['example']))
69
+ input_flags = InputFlags(InputFlag('ssh'))
70
+ self.assertEqual(router._validate_input_flags(command, input_flags), False)
71
+
72
+ def test_validate_correct_input_flag1(self):
73
+ command = Command('cmd', flags=Flag('port'))
74
+ input_flags = InputFlags(InputFlag('port', value='some2'))
75
+ self.assertEqual(Router()._validate_input_flags(command, input_flags), True)
76
+
77
+ def test_validate_correct_input_flag2(self):
78
+ command = Command('cmd', flags=Flag('port', possible_values=['some2', 'some3']))
79
+ input_flags = InputFlags(InputFlag('port', value='some2'))
80
+ self.assertEqual(Router()._validate_input_flags(command, input_flags), True)
81
+
82
+ def test_validate_correct_input_flag3(self):
83
+ command = Command('cmd', flags=Flag('ssh', possible_values=re.compile(r'more[1-5]$')))
84
+ input_flags = InputFlags(InputFlag('ssh', value='more5'))
85
+ self.assertEqual(Router()._validate_input_flags(command, input_flags), True)
86
+
87
+ def test_validate_correct_input_flag4(self):
88
+ command = Command('cmd', flags=Flag('ssh', possible_values=False))
89
+ input_flags = InputFlags(InputFlag('ssh'))
90
+ self.assertEqual(Router()._validate_input_flags(command, input_flags), True)
91
+
92
+ def test_validate_incorrect_func_args1(self):
93
+ command = Command('cmd', flags=Flag('port'))
94
+ def handler():
95
+ pass
96
+ with self.assertRaises(RequiredArgumentNotPassedException):
97
+ Router()._validate_func_args(command, handler)
98
+
99
+ def test_validate_incorrect_func_args2(self):
100
+ command = Command('cmd', flags=Flag('port'))
101
+ def handler(args, kwargs):
102
+ pass
103
+ with self.assertRaises(TooManyTransferredArgsException):
104
+ Router()._validate_func_args(command, handler)
105
+
106
+ def test_validate_incorrect_func_args3(self):
107
+ command = Command('cmd')
108
+ def handler(args):
109
+ pass
110
+ with self.assertRaises(TooManyTransferredArgsException):
111
+ Router()._validate_func_args(command, handler)
112
+
113
+ def test_get_router_aliases(self):
114
+ router = Router()
115
+ @router.command(Command('some', aliases=['test', 'case']))
116
+ def handler():
117
+ pass
118
+ self.assertListEqual(router.get_aliases(), ['test', 'case'])
119
+
120
+ def test_get_router_aliases2(self):
121
+ router = Router()
122
+ @router.command(Command('some', aliases=['test', 'case']))
123
+ def handler():
124
+ pass
125
+ @router.command(Command('ext', aliases=['more', 'foo']))
126
+ def handler2():
127
+ pass
128
+ self.assertListEqual(router.get_aliases(), ['test', 'case', 'more', 'foo'])
129
+
130
+ def test_get_router_aliases3(self):
131
+ router = Router()
132
+ @router.command(Command('some'))
133
+ def handler():
134
+ pass
135
+ self.assertListEqual(router.get_aliases(), [])
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
@@ -1,15 +0,0 @@
1
- import argparse
2
-
3
-
4
- parser = argparse.ArgumentParser(prog='ProgramName',
5
- description='What the program does',
6
- epilog='Text at the bottom of help')
7
-
8
- parser.add_argument('filename') # positional argument
9
- parser.add_argument('-c', '--count') # option that takes a value
10
- parser.add_argument('-v',
11
- action='store_const')
12
-
13
- args = parser.parse_args()
14
- print(args)
15
- print(args.filename, args.count, args.verbose)
@@ -1,4 +0,0 @@
1
- __all__ = ["Router"]
2
-
3
-
4
- from argenta.router.entity import Router
@@ -1,26 +0,0 @@
1
- from argenta.command.flag.models import Flag, Flags
2
-
3
- import unittest
4
-
5
-
6
- class TestFlags(unittest.TestCase):
7
- def test_get_flags(self):
8
- flags = Flags()
9
- list_of_flags = [
10
- Flag('test1'),
11
- Flag('test2'),
12
- Flag('test3'),
13
- ]
14
- flags.add_flags(list_of_flags)
15
- self.assertEqual(flags.get_flags(),
16
- list_of_flags)
17
-
18
- def test_add_flag(self):
19
- flags = Flags()
20
- flags.add_flag(Flag('test'))
21
- self.assertEqual(len(flags.get_flags()), 1)
22
-
23
- def test_add_flags(self):
24
- flags = Flags()
25
- flags.add_flags([Flag('test'), Flag('test2')])
26
- self.assertEqual(len(flags.get_flags()), 2)
@@ -1,33 +0,0 @@
1
- from src.argenta.router import Router
2
- from src.argenta.command import Command
3
- from src.argenta.router import TriggerContainSpacesException
4
-
5
- import unittest
6
-
7
-
8
- class TestRouter(unittest.TestCase):
9
- def test_get_router_title(self):
10
- self.assertEqual(Router(title='test title').get_title(), 'test title')
11
-
12
- def test_register_command_with_spaces_in_trigger(self):
13
- router = Router()
14
- with self.assertRaises(TriggerContainSpacesException):
15
- @router.command(Command(trigger='command with spaces'))
16
- def test():
17
- return 'correct result'
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes