new models, a model is passed to the command handler instead of a dictionary, removal of checks for intersection of processed triggers in handlers and much, much more

This commit is contained in:
2025-03-31 19:14:42 +03:00
parent 2918bc9f81
commit 5c6fa5151a
24 changed files with 283 additions and 279 deletions
+6 -9
View File
@@ -1,4 +1,4 @@
from argenta.command import Command
from argenta.command.models import InputCommand
from argenta.command.exceptions import (UnprocessedInputFlagException,
RepeatedInputFlagsException,
EmptyInputCommandException)
@@ -6,22 +6,19 @@ from argenta.command.exceptions import (UnprocessedInputFlagException,
import unittest
class TestCommand(unittest.TestCase):
class TestInputCommand(unittest.TestCase):
def test_parse_correct_raw_command(self):
self.assertEqual(Command.parse_input_command('ssh --host 192.168.0.3').get_trigger(), 'ssh')
self.assertEqual(InputCommand.parse_input_command('ssh --host 192.168.0.3').get_trigger(), 'ssh')
def test_parse_raw_command_without_flag_name_with_value(self):
with self.assertRaises(UnprocessedInputFlagException):
Command.parse_input_command('ssh 192.168.0.3')
InputCommand.parse_input_command('ssh 192.168.0.3')
def test_parse_raw_command_with_repeated_flag_name(self):
with self.assertRaises(RepeatedInputFlagsException):
Command.parse_input_command('ssh --host 192.168.0.3 --host 172.198.0.43')
InputCommand.parse_input_command('ssh --host 192.168.0.3 --host 172.198.0.43')
def test_parse_empty_raw_command(self):
with self.assertRaises(EmptyInputCommandException):
Command.parse_input_command('')
def test_get_command_description(self):
self.assertEqual(Command(trigger='test', description='test description').get_description(), 'test description')
InputCommand.parse_input_command('')