mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
refactor: unify site chain data port access
This commit is contained in:
@@ -467,6 +467,25 @@ def test_music_chain_uses_explicit_subscribe_data_port_getter():
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_site_chains_use_explicit_site_data_port_getter():
|
||||
"""站点与种子链不得把 SitePortProxy 伪装成 SiteOper。"""
|
||||
paths = [APP_ROOT / "chain" / "site.py", APP_ROOT / "chain" / "torrents.py"]
|
||||
violations: list[str] = []
|
||||
for path in paths:
|
||||
tree = ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.ImportFrom):
|
||||
continue
|
||||
if node.module != "app.application.chain.data":
|
||||
continue
|
||||
if any(alias.name == "SitePortProxy" for alias in node.names):
|
||||
violations.append(
|
||||
f"{path.relative_to(PROJECT_ROOT).as_posix()}:{node.lineno}"
|
||||
)
|
||||
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_plugin_components_do_not_reexport_legacy_abi_names():
|
||||
"""新插件组件只提供 canonical 能力,不得复制旧 Helper、Manager 或 Oper 导出。"""
|
||||
violations: list[str] = []
|
||||
|
||||
@@ -209,7 +209,10 @@ class TestSlashCommandInteractions(unittest.TestCase):
|
||||
)
|
||||
]
|
||||
|
||||
with patch("app.chain.site.SiteOper.list", return_value=fake_sites), patch.object(
|
||||
with patch(
|
||||
"app.chain.site.get_chain_site_port",
|
||||
return_value=SimpleNamespace(list=lambda: fake_sites),
|
||||
), patch.object(
|
||||
chain, "post_message"
|
||||
) as post_message:
|
||||
chain.remote_list(channel=NotificationChannel.Web, userid="u1", source="web")
|
||||
|
||||
Reference in New Issue
Block a user