fix: test

This commit is contained in:
Soulter
2026-03-03 16:04:08 +08:00
parent ed84074a60
commit df421e5554
3 changed files with 3 additions and 26 deletions
+2
View File
@@ -846,6 +846,8 @@ def _apply_sandbox_tools(
) -> None: ) -> None:
if req.func_tool is None: if req.func_tool is None:
req.func_tool = ToolSet() req.func_tool = ToolSet()
if req.system_prompt is None:
req.system_prompt = ""
booter = config.sandbox_cfg.get("booter", "shipyard_neo") booter = config.sandbox_cfg.get("booter", "shipyard_neo")
if booter == "shipyard": if booter == "shipyard":
ep = config.sandbox_cfg.get("shipyard_endpoint", "") ep = config.sandbox_cfg.get("shipyard_endpoint", "")
+1 -2
View File
@@ -1,4 +1,5 @@
import json import json
import os
import shutil import shutil
import uuid import uuid
from pathlib import Path from pathlib import Path
@@ -41,8 +42,6 @@ def _discover_bay_credentials(endpoint: str) -> str:
Returns: Returns:
API key string, or empty string if not found. API key string, or empty string if not found.
""" """
import os
candidates: list[Path] = [] candidates: list[Path] = []
# 1. BAY_DATA_DIR env var # 1. BAY_DATA_DIR env var
-24
View File
@@ -516,30 +516,6 @@ class TestEnsurePersonaAndSkills:
assert "Persona Instructions" not in req.system_prompt assert "Persona Instructions" not in req.system_prompt
@pytest.mark.asyncio
async def test_ensure_skills(self, mock_event, mock_context):
"""Test applying skills to request."""
module = ama
mock_skill = MagicMock()
mock_skill.name = "test_skill"
mock_skill.to_prompt.return_value = "Skill description"
mock_context.persona_manager.personas_v3 = []
mock_context.persona_manager.resolve_selected_persona = AsyncMock(
return_value=(None, None, None, False)
)
with patch("astrbot.core.astr_main_agent.SkillManager") as mock_skill_mgr_cls:
mock_skill_mgr = MagicMock()
mock_skill_mgr.list_skills.return_value = [mock_skill]
mock_skill_mgr_cls.return_value = mock_skill_mgr
req = ProviderRequest()
req.conversation = MagicMock(persona_id=None)
await module._ensure_persona_and_skills(req, {}, mock_context, mock_event)
assert "test_skill" in req.system_prompt
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_ensure_tools_from_persona(self, mock_event, mock_context): async def test_ensure_tools_from_persona(self, mock_event, mock_context):
"""Test applying tools from persona.""" """Test applying tools from persona."""