work on docs

This commit is contained in:
2025-03-04 18:44:45 +03:00
parent 2c9c8da13c
commit 971258728c
5 changed files with 106 additions and 44 deletions
+92
View File
@@ -1,6 +1,7 @@
from argenta.command.params.flag import FlagsGroup, Flag
from argenta.router import Router
from argenta.command import Command
from argenta.router.exceptions import RepeatedCommandException
import unittest
@@ -32,3 +33,94 @@ class TestRouter(unittest.TestCase):
input_command.set_input_flags(FlagsGroup([Flag('host')]))
self.assertEqual(router.input_command_handler(input_command), None)
def test_input_correct_command_with_one_register_and_ignore_command_register(self):
router = Router()
router.set_ignore_command_register(True)
@router.command(Command(command='test'))
def test():
return 'correct result'
self.assertEqual(router.input_command_handler(Command(command='test')), 'correct result')
def test_input_correct_command_with_different_register_and_ignore_command_register(self):
router = Router()
router.set_ignore_command_register(True)
@router.command(Command(command='test'))
def test():
return 'correct result'
self.assertEqual(router.input_command_handler(Command(command='TeSt')), 'correct result')
def test_input_incorrect_command_with_ignore_command_register(self):
router = Router()
router.set_ignore_command_register(True)
@router.command(Command(command='test'))
def test():
return 'correct result'
self.assertEqual(router.input_command_handler(Command(command='Test2')), None)
def test_register_repeated_commands_with_one_register(self):
router = Router()
@router.command(Command(command='test'))
def test():
return 'correct result'
with self.assertRaises(RepeatedCommandException):
@router.command(Command(command='test'))
def test():
return 'correct result'
def test_register_commands_with_different_register(self):
router = Router()
@router.command(Command(command='test'))
def test():
return 'correct result'
try:
@router.command(Command(command='Test'))
def test():
return 'correct result'
except RepeatedCommandException:
self.fail('RepeatedCommandException should not have been thrown')
def test_register_repeated_commands_with_one_register_and_set_ignore_command_register(self):
router = Router()
router.set_ignore_command_register(True)
@router.command(Command(command='test'))
def test():
return 'correct result'
with self.assertRaises(RepeatedCommandException):
@router.command(Command(command='test'))
def test():
return 'correct result'
def test_register_repeated_commands_with_different_register_and_set_ignore_command_register(self):
router = Router()
router.set_ignore_command_register(True)
@router.command(Command(command='test'))
def test():
return 'correct result'
with self.assertRaises(RepeatedCommandException):
@router.command(Command(command='Test'))
def test():
return 'correct result'