Skip to content

Commit ddda2ba

Browse files
committed
test: update start_daemon_services test to target renamed helper after rebase
The rebase onto post-#276 main removed src/orb/interface/serve_command_handler.py and moved the daemon-services init call into server_command_handlers._initialize_application. Redirect the test at the new target and drop unused sys/types imports.
1 parent d05906c commit ddda2ba

1 file changed

Lines changed: 6 additions & 42 deletions

File tree

tests/unit/application/test_start_daemon_services.py

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from __future__ import annotations
44

55
import asyncio
6-
import sys
7-
import types
86
from typing import Any
97
from unittest.mock import AsyncMock, MagicMock, patch
108

@@ -163,59 +161,25 @@ async def test_returns_true_when_all_strategies_succeed() -> None:
163161

164162

165163
@pytest.mark.asyncio
166-
async def test_serve_command_handler_calls_start_daemon_services() -> None:
167-
"""The REST serve path invokes orb_app.start_daemon_services() after initialize
168-
completes successfully."""
169-
# Build lightweight stand-in modules for all heavy local-import targets
170-
# so the handler never reaches actual DI / file-system code.
171-
fake_uvicorn = types.ModuleType("uvicorn")
172-
fake_server = AsyncMock()
173-
fake_server.serve = AsyncMock(return_value=None)
174-
fake_uvicorn.Server = MagicMock(return_value=fake_server)
175-
fake_uvicorn.Config = MagicMock(return_value=MagicMock())
176-
177-
fake_fastapi_app = MagicMock()
178-
164+
async def test_server_initialize_application_calls_start_daemon_services() -> None:
165+
"""The REST server initialisation path invokes orb_app.start_daemon_services()
166+
after Application.initialize() completes successfully."""
179167
fake_app = MagicMock()
180168
fake_app.initialize = AsyncMock(return_value=True)
181169
fake_app.start_daemon_services = AsyncMock(return_value=True)
182170

183-
fake_server_config = MagicMock()
184-
fake_server_config.host = "127.0.0.1"
185-
fake_server_config.port = 8000
186-
fake_server_config.workers = 1
187-
fake_server_config.log_level = "info"
188-
189171
fake_container = MagicMock()
190172
fake_config_manager = MagicMock()
191-
fake_config_manager.get_typed_with_defaults.return_value = fake_server_config
192173
fake_config_manager._config_file = None
193174
fake_container.get.return_value = fake_config_manager
194175

195176
with (
196177
patch("orb.infrastructure.di.container.get_container", return_value=fake_container),
197-
patch("orb.api.server.create_fastapi_app", return_value=fake_fastapi_app),
198178
patch("orb.bootstrap.Application", return_value=fake_app),
199179
):
200-
# Inject uvicorn as a temporary sys.modules entry so the try/import
201-
# inside handle_serve_api succeeds without the real package.
202-
sys.modules.setdefault("uvicorn", fake_uvicorn)
203-
try:
204-
from orb.interface.serve_command_handler import handle_serve_api # noqa: PLC0415
205-
206-
args = MagicMock()
207-
args.host = "127.0.0.1"
208-
args.port = 8000
209-
args.workers = 1
210-
args.reload = False
211-
args.server_log_level = "info"
212-
args.socket_path = None
213-
args.scheduler = None
214-
215-
await handle_serve_api(args)
216-
finally:
217-
# Only remove if we added it (it was setdefault above).
218-
pass
180+
from orb.interface.server_command_handlers import _initialize_application # noqa: PLC0415
181+
182+
await _initialize_application()
219183

220184
fake_app.start_daemon_services.assert_awaited_once()
221185

0 commit comments

Comments
 (0)