fix: tests, imports

This commit is contained in:
2025-10-11 19:37:23 +03:00
parent e481ee8775
commit 2b76bea318
5 changed files with 26 additions and 9 deletions
+5 -3
View File
@@ -1,3 +1,5 @@
from argenta.app.models import App as App __all__ = ["App", "Orchestrator", "Router"]
from argenta.orchestrator.entity import Orchestrator as Orchestrator
from argenta.router.entity import Router as Router
from argenta.orchestrator.entity import Orchestrator, App
from argenta.router.entity import Router
+2 -3
View File
@@ -1,5 +1,4 @@
__all__ = [ __all__ = ["ArgParser", "Orchestrator"]
"ArgParser",
]
from argenta.orchestrator.argparser.entity import ArgParser from argenta.orchestrator.argparser.entity import ArgParser
from argenta.orchestrator.entity import Orchestrator
+1 -1
View File
@@ -1,4 +1,4 @@
from argenta.app import App from argenta.app.models import App
from argenta.orchestrator.argparser import ArgParser from argenta.orchestrator.argparser import ArgParser
from argenta.orchestrator.argparser.entity import ArgSpace from argenta.orchestrator.argparser.entity import ArgSpace
@@ -3,6 +3,7 @@ from unittest.mock import patch, MagicMock
from unittest import TestCase from unittest import TestCase
import io import io
import re import re
import sys
from argenta.command import Command, PredefinedFlags from argenta.command import Command, PredefinedFlags
from argenta.command.flag.models import ValidationStatus from argenta.command.flag.models import ValidationStatus
@@ -11,8 +12,15 @@ from argenta import Orchestrator, App, Router
from argenta.response import Response from argenta.response import Response
class PatchedArgvTestCase(TestCase):
def setUp(self):
super().setUp()
self.patcher = patch.object(sys, 'argv', ['program.py'])
self.mock_argv = self.patcher.start()
self.addCleanup(self.patcher.stop)
class TestSystemHandlerNormalWork(TestCase):
class TestSystemHandlerNormalWork(PatchedArgvTestCase):
@patch("builtins.input", side_effect=["help", "q"]) @patch("builtins.input", side_effect=["help", "q"])
@patch("sys.stdout", new_callable=io.StringIO) @patch("sys.stdout", new_callable=io.StringIO)
def test_input_incorrect_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock): def test_input_incorrect_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock):
@@ -3,6 +3,7 @@ from unittest.mock import patch, MagicMock
from unittest import TestCase from unittest import TestCase
import io import io
import re import re
import sys
from argenta.command import Command, PredefinedFlags from argenta.command import Command, PredefinedFlags
from argenta.command.flag.models import PossibleValues, ValidationStatus from argenta.command.flag.models import PossibleValues, ValidationStatus
@@ -12,8 +13,15 @@ from argenta.command.flag import Flag
from argenta.command.flag.flags import Flags from argenta.command.flag.flags import Flags
class PatchedArgvTestCase(TestCase):
def setUp(self):
super().setUp()
self.patcher = patch.object(sys, 'argv', ['program.py'])
self.mock_argv = self.patcher.start()
self.addCleanup(self.patcher.stop)
class TestSystemHandlerNormalWork(TestCase):
class TestSystemHandlerNormalWork(PatchedArgvTestCase):
@patch("builtins.input", side_effect=["test", "q"]) @patch("builtins.input", side_effect=["test", "q"])
@patch("sys.stdout", new_callable=io.StringIO) @patch("sys.stdout", new_callable=io.StringIO)
def test_input_correct_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock): def test_input_correct_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock):