From de6d35205cb8596905322efab331732c8c528396 Mon Sep 17 00:00:00 2001 From: kolo Date: Tue, 10 Feb 2026 14:03:37 +0300 Subject: [PATCH] rename orchestrator method start_polling to run_repl --- docs/code_snippets/argparser/snippet.py | 4 +- docs/code_snippets/argspace/snippet.py | 2 +- docs/code_snippets/orchestrator/snippet.py | 2 +- .../quickstart/calculator_app.py | 2 +- docs/code_snippets/quickstart/main.py | 2 +- docs/code_snippets/quickstart/simple_app.py | 2 +- .../quickstart/task_manager/main.py | 2 +- docs/code_snippets/testing/app_e2e_test.py | 2 +- docs/root/api/app/index.rst | 2 +- docs/root/api/orchestrator/index.rst | 2 +- docs/root/testing.rst | 2 +- metrics/__main__.py | 2 +- mock/min_app/main.py | 2 +- mock/mock_app/main.py | 2 +- src/argenta/_cli/__main__.py | 8 +-- src/argenta/_cli/commands/init.py | 4 +- src/argenta/_cli/commands/new.py | 4 +- src/argenta/app/models.py | 2 +- src/argenta/app/protocols.py | 1 - src/argenta/orchestrator/entity.py | 4 +- ...t_system_handling_non_standard_behavior.py | 18 ++--- .../test_system_handling_normal_behavior.py | 18 ++--- tests/unit_tests/test_orchestrator.py | 71 +++++++++---------- 23 files changed, 79 insertions(+), 81 deletions(-) diff --git a/docs/code_snippets/argparser/snippet.py b/docs/code_snippets/argparser/snippet.py index 4553e7c..ba969db 100644 --- a/docs/code_snippets/argparser/snippet.py +++ b/docs/code_snippets/argparser/snippet.py @@ -12,6 +12,6 @@ orchestrator = Orchestrator( if __name__ == "__main__": if arg_parser.parsed_argspace.get_by_name("dev"): - orchestrator.start_polling(App(initial_message="ArgentaDev")) + orchestrator.run_repl(App(initial_message="ArgentaDev")) else: - orchestrator.start_polling(App()) + orchestrator.run_repl(App()) diff --git a/docs/code_snippets/argspace/snippet.py b/docs/code_snippets/argspace/snippet.py index 3c22275..df90288 100644 --- a/docs/code_snippets/argspace/snippet.py +++ b/docs/code_snippets/argspace/snippet.py @@ -22,7 +22,7 @@ def main(): print(f" Host: {host.value}") print(f" Port: {port.value}") - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": diff --git a/docs/code_snippets/orchestrator/snippet.py b/docs/code_snippets/orchestrator/snippet.py index 62404cb..fce177c 100644 --- a/docs/code_snippets/orchestrator/snippet.py +++ b/docs/code_snippets/orchestrator/snippet.py @@ -24,4 +24,4 @@ orchestrator = Orchestrator(custom_providers=[ConnectionProvider()]) # 4. Start the application if __name__ == "__main__": - orchestrator.start_polling(app) + orchestrator.run_repl(app) diff --git a/docs/code_snippets/quickstart/calculator_app.py b/docs/code_snippets/quickstart/calculator_app.py index b48b7a9..2b61cc9 100644 --- a/docs/code_snippets/quickstart/calculator_app.py +++ b/docs/code_snippets/quickstart/calculator_app.py @@ -60,7 +60,7 @@ orchestrator = Orchestrator() def main(): app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": diff --git a/docs/code_snippets/quickstart/main.py b/docs/code_snippets/quickstart/main.py index 8e22500..6497682 100644 --- a/docs/code_snippets/quickstart/main.py +++ b/docs/code_snippets/quickstart/main.py @@ -9,7 +9,7 @@ orchestrator: Orchestrator = Orchestrator() def main() -> None: app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": diff --git a/docs/code_snippets/quickstart/simple_app.py b/docs/code_snippets/quickstart/simple_app.py index 96c7179..b7ef6b3 100644 --- a/docs/code_snippets/quickstart/simple_app.py +++ b/docs/code_snippets/quickstart/simple_app.py @@ -30,4 +30,4 @@ app.include_router(main_router) # 5. Start application if __name__ == "__main__": - orchestrator.start_polling(app) + orchestrator.run_repl(app) diff --git a/docs/code_snippets/quickstart/task_manager/main.py b/docs/code_snippets/quickstart/task_manager/main.py index 3d9ffae..eef76e1 100644 --- a/docs/code_snippets/quickstart/task_manager/main.py +++ b/docs/code_snippets/quickstart/task_manager/main.py @@ -15,4 +15,4 @@ app.include_router(router) # 3. Start polling via orchestrator if __name__ == "__main__": - orchestrator.start_polling(app) + orchestrator.run_repl(app) diff --git a/docs/code_snippets/testing/app_e2e_test.py b/docs/code_snippets/testing/app_e2e_test.py index d209d6f..1573d97 100644 --- a/docs/code_snippets/testing/app_e2e_test.py +++ b/docs/code_snippets/testing/app_e2e_test.py @@ -25,7 +25,7 @@ def test_input_incorrect_command(capsys: CaptureFixture[str]): app.set_unknown_command_handler(lambda command: print(f"Unknown command: {command.trigger}")) with patch("builtins.input", side_effect=["help", "q"]): - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out assert "\nUnknown command: help\n" in output diff --git a/docs/root/api/app/index.rst b/docs/root/api/app/index.rst index cc4462a..b84b3d7 100644 --- a/docs/root/api/app/index.rst +++ b/docs/root/api/app/index.rst @@ -159,7 +159,7 @@ PredefinedMessages app.add_message_on_startup(PredefinedMessages.AUTOCOMPLETE) app.add_message_on_startup(PredefinedMessages.HELP) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() diff --git a/docs/root/api/orchestrator/index.rst b/docs/root/api/orchestrator/index.rst index 949126a..4aefbb7 100644 --- a/docs/root/api/orchestrator/index.rst +++ b/docs/root/api/orchestrator/index.rst @@ -36,7 +36,7 @@ Orchestrator Основные методы ---------------- -.. py:method:: start_polling(self, app: App) -> None +.. py:method:: run_repl(self, app: App) -> None Это главный метод, который запускает приложение. Он запускает бесконечный цикл ввода -> вывода. diff --git a/docs/root/testing.rst b/docs/root/testing.rst index f5a5be6..06bbfe0 100644 --- a/docs/root/testing.rst +++ b/docs/root/testing.rst @@ -45,7 +45,7 @@ E2E-тестирование цикла ---------------------- -Полный запуск цикла ``start_polling`` можно покрывать через подпроцесс с передачей строк в ``stdin``. Это тяжелее и обычно не требуется. Если всё же необходимо — пример ниже. +Полный запуск цикла ``run_repl`` можно покрывать через подпроцесс с передачей строк в ``stdin``. Это тяжелее и обычно не требуется. Если всё же необходимо — пример ниже. .. danger:: **Важно:** Обязательно передавайте строковый триггер команды выхода последним элементом в списке ``side_effects`` при патче ``input``. diff --git a/metrics/__main__.py b/metrics/__main__.py index 1f7fc08..1fd6d1f 100644 --- a/metrics/__main__.py +++ b/metrics/__main__.py @@ -12,7 +12,7 @@ def main() -> None: app.set_description_message_pattern( lambda command, description: f'[bold cyan]▸[/bold cyan] [bold white]{command}[/bold white] [dim]│[/dim] [yellow italic]{description}[/yellow italic]' ) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": diff --git a/mock/min_app/main.py b/mock/min_app/main.py index 87e534c..2b87ac6 100644 --- a/mock/min_app/main.py +++ b/mock/min_app/main.py @@ -9,7 +9,7 @@ orchestrator: Orchestrator = Orchestrator() def main() -> None: app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == '__main__': main() diff --git a/mock/mock_app/main.py b/mock/mock_app/main.py index a2ae601..b356c24 100644 --- a/mock/mock_app/main.py +++ b/mock/mock_app/main.py @@ -19,7 +19,7 @@ def main(): app.add_message_on_startup(PredefinedMessages.AUTOCOMPLETE) app.add_message_on_startup(PredefinedMessages.HELP) - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() diff --git a/src/argenta/_cli/__main__.py b/src/argenta/_cli/__main__.py index 08a7483..5016f60 100644 --- a/src/argenta/_cli/__main__.py +++ b/src/argenta/_cli/__main__.py @@ -3,11 +3,11 @@ from typer import Typer from .commands import run_handler, init_handler, new_handler -def main(): +def main() -> None: app = Typer() - app.command("run")(run_handler) - app.command("init")(init_handler) - app.command("new")(new_handler) + app.command("run", help='Command to start the orchestrator repl; the path to the orchestrator is required')(run_handler) + app.command("init", help="Creates a flat/src boilerplate architecture in an existing project")(init_handler) + app.command("new", help="Creates a project and in it flat/src boilerplate architecture")(new_handler) app() if __name__ == '__main__': diff --git a/src/argenta/_cli/commands/init.py b/src/argenta/_cli/commands/init.py index 2f58773..0406eb2 100644 --- a/src/argenta/_cli/commands/init.py +++ b/src/argenta/_cli/commands/init.py @@ -22,7 +22,7 @@ def main(): app.include_router(router) orchestrator = Orchestrator() - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() @@ -49,7 +49,7 @@ def main(): app.include_router(router) orchestrator = Orchestrator() - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() diff --git a/src/argenta/_cli/commands/new.py b/src/argenta/_cli/commands/new.py index e609691..b5ced3c 100644 --- a/src/argenta/_cli/commands/new.py +++ b/src/argenta/_cli/commands/new.py @@ -24,7 +24,7 @@ def main(): app.include_router(router) orchestrator = Orchestrator() - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() @@ -51,7 +51,7 @@ def main(): app.include_router(router) orchestrator = Orchestrator() - orchestrator.start_polling(app) + orchestrator.run_repl(app) if __name__ == "__main__": main() diff --git a/src/argenta/app/models.py b/src/argenta/app/models.py index 91ff7af..5d163f3 100644 --- a/src/argenta/app/models.py +++ b/src/argenta/app/models.py @@ -144,7 +144,7 @@ class BaseApp(BehaviorHandlersSettersMixin): is_stdout_redirected_by_router=processing_router.is_redirect_stdout_disabled ) - def _run_polling(self) -> None: + def _run_repl(self) -> None: self._viewer.view_initial_message(self._initial_message) self._pre_cycle_setup() while True: diff --git a/src/argenta/app/protocols.py b/src/argenta/app/protocols.py index ab19d22..eb9f036 100644 --- a/src/argenta/app/protocols.py +++ b/src/argenta/app/protocols.py @@ -9,7 +9,6 @@ __all__ = [ from typing import Any, Protocol, TypeVar, Callable -from argenta.response import Response T = TypeVar("T", contravariant=True) diff --git a/src/argenta/orchestrator/entity.py b/src/argenta/orchestrator/entity.py index 9656fb0..0832c51 100644 --- a/src/argenta/orchestrator/entity.py +++ b/src/argenta/orchestrator/entity.py @@ -30,7 +30,7 @@ class Orchestrator: if self._arg_parser is not None: self._arg_parser._parse_args() - def start_polling(self, app: App) -> None: + def run_repl(self, app: App) -> None: """ Public. Starting the user input processing cycle :param app: a running application @@ -41,4 +41,4 @@ class Orchestrator: ) setup_dishka(app, container, auto_inject=self._auto_inject_handlers) - app._run_polling() + app._run_repl() diff --git a/tests/system_tests/test_system_handling_non_standard_behavior.py b/tests/system_tests/test_system_handling_non_standard_behavior.py index 4a65aba..6049353 100644 --- a/tests/system_tests/test_system_handling_non_standard_behavior.py +++ b/tests/system_tests/test_system_handling_non_standard_behavior.py @@ -38,7 +38,7 @@ def test_empty_input_triggers_empty_command_handler(monkeypatch: pytest.MonkeyPa app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_empty_command_handler(lambda: print('Empty input command')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -64,7 +64,7 @@ def test_unknown_command_triggers_unknown_command_handler(monkeypatch: pytest.Mo app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.trigger}')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -85,7 +85,7 @@ def test_mixed_valid_and_unknown_commands_handled_correctly(monkeypatch: pytest. app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.trigger}')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -110,7 +110,7 @@ def test_multiple_commands_with_unknown_command_in_between(monkeypatch: pytest.M app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_unknown_command_handler(lambda command: print(f'Unknown command: {command.trigger}')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -137,7 +137,7 @@ def test_unregistered_flag_without_value_is_accessible(monkeypatch: pytest.Monke app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -161,7 +161,7 @@ def test_unregistered_flag_with_value_is_accessible(monkeypatch: pytest.MonkeyPa app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -184,7 +184,7 @@ def test_registered_and_unregistered_flags_coexist(monkeypatch: pytest.MonkeyPat app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -210,7 +210,7 @@ def test_flag_without_value_triggers_incorrect_syntax_handler(monkeypatch: pytes app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_incorrect_input_syntax_handler(lambda command: print(f'Incorrect flag syntax: "{command}"')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -236,7 +236,7 @@ def test_repeated_flags_trigger_repeated_flags_handler(monkeypatch: pytest.Monke app = App(override_system_messages=True, printer=print) app.include_router(router) app.set_repeated_input_flags_handler(lambda command: print(f'Repeated input flags: "{command}"')) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out diff --git a/tests/system_tests/test_system_handling_normal_behavior.py b/tests/system_tests/test_system_handling_normal_behavior.py index e7bf0de..0fbd09a 100644 --- a/tests/system_tests/test_system_handling_normal_behavior.py +++ b/tests/system_tests/test_system_handling_normal_behavior.py @@ -38,7 +38,7 @@ def test_simple_command_executes_successfully(monkeypatch: pytest.MonkeyPatch, c app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -62,7 +62,7 @@ def test_two_commands_execute_sequentially(monkeypatch: pytest.MonkeyPatch, caps app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -90,7 +90,7 @@ def test_three_commands_execute_sequentially(monkeypatch: pytest.MonkeyPatch, ca app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -118,7 +118,7 @@ def test_custom_flag_without_value_is_recognized(monkeypatch: pytest.MonkeyPatch app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -141,7 +141,7 @@ def test_custom_flag_with_regex_validation_accepts_valid_value(monkeypatch: pyte app = App(override_system_messages=True, repeat_command_groups_printing=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -169,7 +169,7 @@ def test_predefined_short_help_flag_is_recognized(monkeypatch: pytest.MonkeyPatc app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -192,7 +192,7 @@ def test_predefined_info_flag_is_recognized(monkeypatch: pytest.MonkeyPatch, cap app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -215,7 +215,7 @@ def test_predefined_host_flag_with_value_is_recognized(monkeypatch: pytest.Monke app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out @@ -244,7 +244,7 @@ def test_two_predefined_flags_are_recognized_together(monkeypatch: pytest.Monkey app = App(override_system_messages=True, printer=print) app.include_router(router) - orchestrator.start_polling(app) + orchestrator.run_repl(app) output = capsys.readouterr().out diff --git a/tests/unit_tests/test_orchestrator.py b/tests/unit_tests/test_orchestrator.py index c2b7f27..44fa194 100644 --- a/tests/unit_tests/test_orchestrator.py +++ b/tests/unit_tests/test_orchestrator.py @@ -45,12 +45,11 @@ def sample_router() -> Router: # ============================================================================ -def test_orchestrator_initializes_with_default_argparser(mocker: MockerFixture) -> None: - """Test Orchestrator initialization with default ArgParser""" +def test_orchestrator_initializes_with_no_argparser(mocker: MockerFixture) -> None: + """Test Orchestrator initialization with no ArgParser""" mocker.patch('sys.argv', ['test_program']) orchestrator = Orchestrator() - assert orchestrator._arg_parser is not None - assert isinstance(orchestrator._arg_parser, ArgParser) + assert orchestrator._arg_parser is None def test_orchestrator_initializes_with_custom_argparser(mock_argparser: ArgParser) -> None: @@ -89,80 +88,80 @@ def test_orchestrator_parses_args_on_initialization(mocker: MockerFixture, mock_ # ============================================================================ -# Tests for start_polling method +# Tests for run_repl method # ============================================================================ -def test_start_polling_creates_dishka_container( +def test_run_repl_creates_dishka_container( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: - """Test that start_polling creates a dishka container""" + """Test that run_repl creates a dishka container""" mock_make_container = mocker.patch('argenta.orchestrator.entity.make_container') _mock_setup_dishka = mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) mock_make_container.assert_called_once() assert mock_make_container.call_args[1]['context'] == {ArgParser: mock_argparser} -def test_start_polling_calls_setup_dishka_with_auto_inject_enabled( +def test_run_repl_calls_setup_dishka_with_auto_inject_enabled( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: - """Test that start_polling calls setup_dishka with auto_inject=True""" + """Test that run_repl calls setup_dishka with auto_inject=True""" mock_container = mocker.MagicMock() # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType] mocker.patch('argenta.orchestrator.entity.make_container', return_value=mock_container) mock_setup_dishka = mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser, auto_inject_handlers=True) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) mock_setup_dishka.assert_called_once_with(sample_app, mock_container, auto_inject=True) -def test_start_polling_calls_setup_dishka_with_auto_inject_disabled( +def test_run_repl_calls_setup_dishka_with_auto_inject_disabled( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: - """Test that start_polling calls setup_dishka with auto_inject=False""" + """Test that run_repl calls setup_dishka with auto_inject=False""" mock_container = mocker.MagicMock() # pyright: ignore[reportUnknownMemberType, reportUnknownVariableType] mocker.patch('argenta.orchestrator.entity.make_container', return_value=mock_container) mock_setup_dishka = mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser, auto_inject_handlers=False) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) mock_setup_dishka.assert_called_once_with(sample_app, mock_container, auto_inject=False) -def test_start_polling_calls_app_run_polling( +def test_run_repl_calls_app_run_repl( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: - """Test that start_polling calls app.run_polling()""" + """Test that run_repl calls app.run_polling()""" mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mock_run_polling = mocker.patch.object(sample_app, '_run_polling') + mock_run_repl = mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) - mock_run_polling.assert_called_once() + mock_run_repl.assert_called_once() -def test_start_polling_includes_custom_providers_in_container( +def test_run_repl_includes_custom_providers_in_container( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: - """Test that start_polling includes custom providers in container""" + """Test that run_repl includes custom providers in container""" custom_provider = Provider() mock_make_container = mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser, custom_providers=[custom_provider]) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) # Check that custom_provider was passed to make_container call_args = mock_make_container.call_args[0] @@ -180,14 +179,14 @@ def test_orchestrator_integrates_with_app_with_router( """Test that Orchestrator properly integrates with App that has routers""" mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mock_run_polling = mocker.patch.object(sample_app, '_run_polling') + mock_run_repl = mocker.patch.object(sample_app, '_run_repl') sample_app.include_router(sample_router) orchestrator = Orchestrator(arg_parser=mock_argparser) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) - mock_run_polling.assert_called_once() + mock_run_repl.assert_called_once() assert len(sample_app.registered_routers.registered_routers) == 1 @@ -202,10 +201,10 @@ def test_orchestrator_passes_argparser_to_container_context( """Test that Orchestrator passes ArgParser instance to container context""" mock_make_container = mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator(arg_parser=mock_argparser) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) # Verify that ArgParser was passed in context call_kwargs = mock_make_container.call_args[1] @@ -219,18 +218,18 @@ def test_orchestrator_passes_argparser_to_container_context( # ============================================================================ -def test_orchestrator_handles_app_run_polling_exception( +def test_orchestrator_handles_app_run_repl_exception( mocker: MockerFixture, mock_argparser: ArgParser, sample_app: App ) -> None: """Test that Orchestrator propagates exceptions from app.run_polling()""" mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling', side_effect=RuntimeError("Test error")) + mocker.patch.object(sample_app, '_run_repl', side_effect=RuntimeError("Test error")) orchestrator = Orchestrator(arg_parser=mock_argparser) with pytest.raises(RuntimeError, match="Test error"): - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) # ============================================================================ @@ -246,13 +245,13 @@ def test_orchestrator_accepts_multiple_custom_providers( provider2 = Provider() mock_make_container = mocker.patch('argenta.orchestrator.entity.make_container') mocker.patch('argenta.orchestrator.entity.setup_dishka') - mocker.patch.object(sample_app, '_run_polling') + mocker.patch.object(sample_app, '_run_repl') orchestrator = Orchestrator( arg_parser=mock_argparser, custom_providers=[provider1, provider2] ) - orchestrator.start_polling(sample_app) + orchestrator.run_repl(sample_app) call_args = mock_make_container.call_args[0] assert provider1 in call_args