fix: 修复运行时配置递归与插件兼容入口

This commit is contained in:
jxxghp
2026-08-23 08:57:39 +08:00
parent 4d1be26a31
commit 557f2f18a9
7 changed files with 95 additions and 3 deletions
+11
View File
@@ -19,6 +19,7 @@ from app.application.configuration import (
get_api_runtime_config_snapshot,
get_transfer_retry_config,
)
from app.runtime.settings import RuntimeSettingsCompat, configure_runtime_settings_compat
class _MutableSettings:
@@ -62,6 +63,16 @@ def test_runtime_settings_service_hides_mutable_settings_implementation() -> Non
assert service.get("VALUE") == "final"
def test_runtime_settings_compat_delegates_to_concrete_service_backend() -> None:
"""兼容 Settings 代理委托到真实设置对象时不会在 model_dump 中递归。"""
service = RuntimeSettingsService(_MutableSettings())
configure_runtime_settings_compat(service)
assert RuntimeSettingsCompat().model_dump(include={"VALUE"}) == {
"VALUE": "before"
}
def test_system_config_service_supports_separate_reader_and_writer() -> None:
"""应用服务可以分别注入只读与写入适配器。"""
reader = MagicMock()
+6
View File
@@ -921,6 +921,9 @@ def test_failed_dependency_sync_does_not_replace_program_files(tmp_path: Path) -
(live_app / "app" / "application" / "site").mkdir(parents=True)
live_public.mkdir()
(live_app / "app" / "old.py").write_text("old", encoding="utf-8")
(live_app / "app" / "plugins" / "__init__.py").write_text(
"# legacy plugin compatibility entrypoint\n", encoding="utf-8"
)
(live_app / "app" / "plugins" / "plugin.py").write_text("plugin", encoding="utf-8")
(live_app / "app" / "application" / "site" / "user.sites.v3.bin").write_text(
"sites", encoding="utf-8"
@@ -931,6 +934,9 @@ def test_failed_dependency_sync_does_not_replace_program_files(tmp_path: Path) -
update_tree = tmp_path / "update" / "App"
(update_tree / "app" / "plugins").mkdir(parents=True)
(update_tree / "app" / "plugins" / "__init__.py").write_text(
"# legacy plugin compatibility entrypoint\n", encoding="utf-8"
)
(update_tree / "pyproject.toml").write_text("[project]\n", encoding="utf-8")
(update_tree / "uv.lock").write_text("version = 1\n", encoding="utf-8")
(update_tree / "version.py").write_text("FRONTEND_VERSION = 'v3.0.1'\n", encoding="utf-8")
+9
View File
@@ -77,6 +77,15 @@ def test_dockerfile_assigns_each_payload_to_an_independent_stage() -> None:
assert "RUN rm -rf /app/frontend-dist" in dockerfile
def test_plugin_runtime_updates_preserve_legacy_base_entrypoint() -> None:
"""更新和性能覆盖镜像必须保留旧插件导入 _PluginBase 所需的兼容入口。"""
update_script = _read(ROOT / "docker" / "update.sh")
perf_script = _read(ROOT / "scripts" / "perf" / "moviepilot_docker_ab.py")
assert 'rm -f "${stage_plugin_dir}/__init__.py"' not in update_script
assert "rm -f /frozen/plugins/__init__.py" not in perf_script
def test_release_workflows_pin_and_record_external_payload_identities() -> None:
"""正式与 Beta 构建都必须以真实制品身份驱动缓存并写入镜像标签。"""
for workflow_path in (RELEASE_WORKFLOW, BETA_WORKFLOW):