Peach: Local-first video metadata scraper and media manager.
test(batch): 补上合批分支漏改的三处用例
longmeidao3e28825f7ab3
diff --git a/tests/test_configuration_sources.py b/tests/test_configuration_sources.pyindex 9f10f2223..6ee0672f8 100644--- a/tests/test_configuration_sources.py+++ b/tests/test_configuration_sources.py@@ -90,6 +90,8 @@ class ConfigurationIsolationTests(unittest.TestCase):stack.enter_context(patch.object(routes, "snapshot", return_value={"media_dirs": [], "port": 8900}))stack.enter_context(patch.object(routes, "network_payload", return_value={"scope": "local"}))stack.enter_context(patch.object(routes, "tunnel_payload", return_value={"state": "idle"}))+ stack.enter_context(patch.object(routes, "api_token_payload", return_value={"rotatable": False}))+ stack.enter_context(patch.object(routes, "certificate_payload", return_value=None))for key, module, name in (("push_discovery", routes, "push_discovery_payload"),("downloads", routes.web_downloads, "settings_payload")):stack.enter_context(patch.object(module, name, side_effect=OSError("private-detail"))diff --git a/tests/test_fastapi_api.py b/tests/test_fastapi_api.pyindex dd1ab7719..76d8ca244 100644--- a/tests/test_fastapi_api.py+++ b/tests/test_fastapi_api.py@@ -4177,6 +4177,10 @@ PUBLIC_ROUTES = {# STRM 的 HLS 子资源供浏览器和外部播放器共用:处理函数验证浏览器会话,# 或绑定资产与 Origin 的限时 HMAC;两条分支都检查媒体根目录及资源归属。("GET,HEAD", "/strm-resource/{id}/{key}"),+ # 本机 CA 的公开证书(ADR-0142)。手机扫码时还没登录、也还没信任这张证书,二维码带进程+ # 密钥签发、十分钟有效的签名,只换得到这张公开证书;处理函数里不带签名的请求照常+ # `require_auth`。私钥不经过这条路由。+ ("GET", "/api/configuration/certificate/peach-local-ca.crt"),}diff --git a/tests/test_onboarding.py b/tests/test_onboarding.pyindex 365591f8a..430d9a927 100644--- a/tests/test_onboarding.py+++ b/tests/test_onboarding.py@@ -1034,15 +1034,21 @@ class StandaloneConfigurationTests(_Case):self.assertEqual(client.get(f"/api/configuration/{path}",headers={"X-Token":"test-token"}).status_code,403)def test_missing_media_tools_have_download_links_in_the_runtime_facts(self):+ """缺工具时:没有发布工具包的平台给官方外链,Windows x64 给「安装」入口(`media_tools.supported`)。"""from peach.web_entry import runtime_fact_entries- for missing_ffmpeg, missing_probe in ((True, True), (False, True), (False, False)):- with self.subTest(ffmpeg=missing_ffmpeg, probe=missing_probe), mock.patch(- "peach.ffmpeg.FFmpegResolver.ffmpeg", return_value=None if missing_ffmpeg else object()), mock.patch(- "peach.ffmpeg.FFmpegResolver.ffprobe", return_value=None if missing_probe else object()):- # 两样都在时 FFmpeg 不占一行,取不到就按没有下载入口算。- fact = next((row for row in runtime_fact_entries(self.config) if row['term'] == 'FFmpeg'), {})- self.assertEqual(fact.get('download_url') == 'https://ffmpeg.org/download.html',- missing_ffmpeg or missing_probe)+ found = mock.Mock(source="path")+ for installable in (False, True):+ for missing_ffmpeg, missing_probe in ((True, True), (False, True), (False, False)):+ with self.subTest(installable=installable, ffmpeg=missing_ffmpeg, probe=missing_probe), mock.patch(+ "peach.ffmpeg.FFmpegResolver.ffmpeg", return_value=None if missing_ffmpeg else found), mock.patch(+ "peach.ffmpeg.FFmpegResolver.ffprobe", return_value=None if missing_probe else found), mock.patch(+ "peach.media_tools.supported", return_value=installable):+ # 两样都在、又不是数据目录里装的那份时,FFmpeg 不占一行,取不到就按没有入口算。+ fact = next((row for row in runtime_fact_entries(self.config) if row['term'] == 'FFmpeg'), {})+ missing = missing_ffmpeg or missing_probe+ self.assertEqual(fact.get('download_url') == 'https://ffmpeg.org/download.html',+ missing and not installable)+ self.assertEqual(fact.get('install_tool') == 'ffmpeg', missing and installable)def test_mount_downloads_follow_os_and_detected_installation(self):from peach.media_configuration import mount_dependencies