mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
refactor: complete command facade migration
This commit is contained in:
+3
-3
@@ -14,7 +14,7 @@
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6500,
|
||||
"edge_sha256": "d143f65c278b6eb1887240583c9ecce7b17a8cf7931a22b4f4cd39f269ac676c",
|
||||
"edge_sha256": "c27b649d471e40e8580426bdee28fdd927be03b7868a1b28bd8d9374c10be280",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -1657,6 +1657,7 @@
|
||||
"app.api.endpoints.agent -> app.api.principal",
|
||||
"app.api.endpoints.agent -> app.api.response",
|
||||
"app.api.endpoints.agent -> app.application",
|
||||
"app.api.endpoints.agent -> app.application.commands",
|
||||
"app.api.endpoints.agent -> app.application.configuration",
|
||||
"app.api.endpoints.agent -> app.application.messaging",
|
||||
"app.api.endpoints.agent -> app.application.messaging.agent",
|
||||
@@ -1666,7 +1667,6 @@
|
||||
"app.api.endpoints.agent -> app.application.security.user",
|
||||
"app.api.endpoints.agent -> app.chain",
|
||||
"app.api.endpoints.agent -> app.chain.message",
|
||||
"app.api.endpoints.agent -> app.command",
|
||||
"app.api.endpoints.agent -> app.runtime",
|
||||
"app.api.endpoints.agent -> app.runtime.config",
|
||||
"app.api.endpoints.agent -> app.runtime.events",
|
||||
@@ -2158,6 +2158,7 @@
|
||||
"app.api.endpoints.site -> app.api.principal",
|
||||
"app.api.endpoints.site -> app.api.response",
|
||||
"app.api.endpoints.site -> app.application",
|
||||
"app.api.endpoints.site -> app.application.commands",
|
||||
"app.api.endpoints.site -> app.application.configuration",
|
||||
"app.api.endpoints.site -> app.application.plugin",
|
||||
"app.api.endpoints.site -> app.application.plugin.runtime",
|
||||
@@ -2168,7 +2169,6 @@
|
||||
"app.api.endpoints.site -> app.chain",
|
||||
"app.api.endpoints.site -> app.chain.site",
|
||||
"app.api.endpoints.site -> app.chain.torrents",
|
||||
"app.api.endpoints.site -> app.command",
|
||||
"app.api.endpoints.site -> app.domain",
|
||||
"app.api.endpoints.site -> app.domain.site",
|
||||
"app.api.endpoints.site -> app.runtime",
|
||||
|
||||
@@ -894,6 +894,21 @@ def test_runtime_consumers_use_plugin_application_facade():
|
||||
assert violations == {}
|
||||
|
||||
|
||||
def test_runtime_consumers_use_command_application_facade():
|
||||
"""Command concrete 实现只允许 startup 组合根直接依赖。"""
|
||||
allowed = {
|
||||
"app.startup.initializers.command",
|
||||
"app.startup.initializers.modules",
|
||||
}
|
||||
violations = {
|
||||
module_name: dependencies & {"app.command"}
|
||||
for module_name, dependencies in _build_module_graph().items()
|
||||
if module_name not in allowed and "app.command" in dependencies
|
||||
}
|
||||
|
||||
assert violations == {}
|
||||
|
||||
|
||||
def test_api_does_not_import_factory():
|
||||
"""装配器(factory)只允许 app.main 使用,HTTP 端点不得回引。"""
|
||||
violations: dict[str, set[str]] = {}
|
||||
|
||||
@@ -290,14 +290,12 @@ def test_build_web_agent_input_attachments_marks_kinds():
|
||||
def test_build_web_agent_command_items_returns_slash_commands():
|
||||
"""WebAgent 命令建议应返回可展示的斜杠命令。"""
|
||||
with patch(
|
||||
"app.api.endpoints.agent.Command",
|
||||
return_value=SimpleNamespace(
|
||||
get_commands=lambda: {
|
||||
"/sites": {"description": "管理站点", "category": "站点"},
|
||||
"hidden": {"description": "忽略", "category": "其他"},
|
||||
"/hidden": {"description": "隐藏", "category": "其他", "show": False},
|
||||
}
|
||||
),
|
||||
"app.api.endpoints.agent.get_commands",
|
||||
return_value={
|
||||
"/sites": {"description": "管理站点", "category": "站点"},
|
||||
"hidden": {"description": "忽略", "category": "其他"},
|
||||
"/hidden": {"description": "隐藏", "category": "其他", "show": False},
|
||||
},
|
||||
):
|
||||
commands = _build_web_agent_command_items()
|
||||
|
||||
@@ -344,8 +342,8 @@ def test_web_agent_stream_returns_error_for_unknown_command():
|
||||
user = SimpleNamespace(id=1, name="admin", is_superuser=True)
|
||||
|
||||
with patch(
|
||||
"app.api.endpoints.agent.Command",
|
||||
return_value=SimpleNamespace(get=lambda _: {}),
|
||||
"app.api.endpoints.agent.get_command",
|
||||
return_value=None,
|
||||
), patch("app.api.endpoints.agent.MessageChain.handle_message") as handle_message:
|
||||
response = asyncio.run(web_agent_stream(payload, request, user))
|
||||
body = "".join(asyncio.run(_collect_streaming_response(response)))
|
||||
|
||||
Reference in New Issue
Block a user