refactor: add configuration dependency ratchet

This commit is contained in:
jxxghp
2026-08-21 21:20:56 +08:00
parent 9df599f502
commit ff0ce8d1c1
16 changed files with 671 additions and 34 deletions
+15
View File
@@ -16,6 +16,21 @@ from app.schemas.types import SystemConfigKey
class TestAgentSystemSettingsTools(unittest.TestCase):
def test_query_system_settings_accepts_injected_reader(self):
"""Agent 配置工具通过窄端口读取授权字段,无需自行构造数据库 Oper。"""
reader = MagicMock()
reader.get.return_value = [{"name": "qb", "enabled": True}]
tool = QuerySystemSettingsTool(
session_id="session-injected",
user_id="10001",
system_config=reader,
)
payload = json.loads(asyncio.run(tool.run(setting_key="Downloaders")))
self.assertTrue(payload["success"])
reader.get.assert_called_once_with(SystemConfigKey.Downloaders)
def test_query_system_settings_returns_exact_systemconfig_value(self):
tool = QuerySystemSettingsTool(session_id="session-1", user_id="10001")