test: 测试套件自隔离与全量离线化(collection 清零 + 杜绝真实网络) (#5873)

This commit is contained in:
InfinityPacer
2026-06-02 12:23:08 +08:00
committed by GitHub
parent 1c41d9f253
commit 437baec620
85 changed files with 14588 additions and 1163 deletions

View File

@@ -6,6 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
from app.agent.tools.impl.query_system_settings import QuerySystemSettingsTool
from app.agent.tools.impl.update_system_settings import UpdateSystemSettingsTool
from app.agent.tools.manager import MoviePilotToolsManager
from app.core.config import settings
class TestAgentSystemSettingsTools(unittest.TestCase):
@@ -102,8 +103,11 @@ class TestAgentSystemSettingsTools(unittest.TestCase):
def test_update_system_settings_updates_basic_settings(self):
tool = UpdateSystemSettingsTool(session_id="session-1", user_id="10001")
with patch(
"app.agent.tools.impl.update_system_settings.settings.update_setting",
# settings 是 pydantic 模型实例,不能直接 patch 其实例方法__setattr__ 会拦截),
# 改 patch 类上的方法;经实例调用时不带 self断言参数不受影响。
with patch.object(
type(settings),
"update_setting",
return_value=(True, ""),
) as update_setting, patch.object(
UpdateSystemSettingsTool,
@@ -141,7 +145,3 @@ class TestAgentSystemSettingsTools(unittest.TestCase):
payload = json.loads(result)
self.assertIn("error", payload)
self.assertIn("系统管理员", payload["error"])
if __name__ == "__main__":
unittest.main()