mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-18 03:34:20 +00:00
test: reconcile master's unit tests with feat/sandbox refactors
The merge from master brought in new unit tests that target pre-refactor
APIs on feat/sandbox. Reconcile each:
- factories/app.py: FakeApp now exposes a Mock skill_mgr (with empty .skills
dict + inert prompt-addition builder) and a Mock pipeline_service so the
PreProcessor skill-index injection branch can run end-to-end in tests.
- pipeline/conftest.py: eagerly import langbot.pkg.pipeline.pipelinemgr so
pipeline.stage is fully initialised before any individual stage test
(preproc, longtext, ...) tries to lazy-load it. Without this preload,
running test_preproc.py in isolation hit a circular-import error via the
stage -> app -> pipelinemgr -> stage chain.
- provider/test_tool_manager.py: ToolManager now probes four loaders
(native -> plugin -> mcp -> skill). Inject inert native + skill mocks in
the execute_func_call fixture and assert all four shutdowns fire.
- utils/test_paths.py: drop the three cwd-dependent _check_if_source_install
cases. The refactor walks Path(__file__).resolve().parents looking for
pyproject.toml + main.py, so cwd no longer factors in and there's no
file read to mock-fail. The positive case and caching test still apply.
- utils/test_version.py: delete entirely. is_newer and compare_version_str
were removed when VersionManager was refactored to use the Space API for
release checks (1b4107a9); the tests targeted a surface that no longer
exists.
This commit is contained in:
+21
-5
@@ -15,7 +15,7 @@ class FakeApp:
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
command_prefix: list[str] = ["/", "!"],
|
||||
command_prefix: list[str] = ['/', '!'],
|
||||
command_enable: bool = True,
|
||||
pipeline_concurrency: int = 10,
|
||||
admins: list[str] | None = None,
|
||||
@@ -40,6 +40,8 @@ class FakeApp:
|
||||
self.telemetry = self._create_mock_telemetry()
|
||||
self.survey = None
|
||||
self.cmd_mgr = self._create_mock_cmd_mgr()
|
||||
self.skill_mgr = self._create_mock_skill_mgr()
|
||||
self.pipeline_service = self._create_mock_pipeline_service()
|
||||
|
||||
# Apply any extra attributes for specific test scenarios
|
||||
for name, value in extra_attrs.items():
|
||||
@@ -98,9 +100,9 @@ class FakeApp:
|
||||
):
|
||||
instance_config = Mock()
|
||||
instance_config.data = {
|
||||
"command": {"prefix": command_prefix, "enable": command_enable},
|
||||
"concurrency": {"pipeline": pipeline_concurrency},
|
||||
"admins": admins,
|
||||
'command': {'prefix': command_prefix, 'enable': command_enable},
|
||||
'concurrency': {'pipeline': pipeline_concurrency},
|
||||
'admins': admins,
|
||||
}
|
||||
return instance_config
|
||||
|
||||
@@ -119,6 +121,20 @@ class FakeApp:
|
||||
cmd_mgr.execute = AsyncMock()
|
||||
return cmd_mgr
|
||||
|
||||
def _create_mock_skill_mgr(self):
|
||||
"""Mock SkillManager that returns no skill index addition by default."""
|
||||
skill_mgr = Mock()
|
||||
skill_mgr.skills = {}
|
||||
skill_mgr.build_skill_aware_prompt_addition = Mock(return_value='')
|
||||
skill_mgr.get_skill_index = Mock(return_value=[])
|
||||
return skill_mgr
|
||||
|
||||
def _create_mock_pipeline_service(self):
|
||||
"""Mock PipelineService.get_pipeline returning empty extensions prefs."""
|
||||
pipeline_service = AsyncMock()
|
||||
pipeline_service.get_pipeline = AsyncMock(return_value={'extensions_preferences': {}})
|
||||
return pipeline_service
|
||||
|
||||
def capture_message(self, message):
|
||||
"""Capture an outbound message for test assertions."""
|
||||
self._outbound_messages.append(message)
|
||||
@@ -134,4 +150,4 @@ class FakeApp:
|
||||
|
||||
def fake_app(**kwargs) -> FakeApp:
|
||||
"""Create a FakeApp instance with optional overrides."""
|
||||
return FakeApp(**kwargs)
|
||||
return FakeApp(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user