From 26c9d242c109a7bfb047e56ad2f1682f6d80ff3a Mon Sep 17 00:00:00 2001 From: saas-backend-agent Date: Mon, 21 Sep 2026 01:51:48 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=20CI=20GPU=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=20lipsync=20=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=B5=B0=20GPU=20=E8=B7=AF=E5=BE=84=E5=AF=BC=E8=87=B4=20call?= =?UTF-8?q?=5Fargs=20=E4=B8=BA=20None?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 环境 USE_GPU_LIPSYNC=true,MagicMock 的 has_available_worker() 返回 truthy MagicMock, 导致 create_job 走 GPU 路径提前 return,submit_lipsync 未被调用,3 个依赖 MediaKit 路径的测试失败: - test_create_job_api_failure: 未抛 MediaKitError - test_create_job_direct_audio_skips_tts: submit_lipsync.call_args 为 None - test_create_job_resigns_oss_urls_before_submit: 同上 在测试中显式设置 svc.settings.use_gpu_lipsync = False,强制走 MediaKit 路径验证相关逻辑。 --- tests/unit/test_lipsync_routes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_lipsync_routes.py b/tests/unit/test_lipsync_routes.py index 8bce520f2..132d6875f 100644 --- a/tests/unit/test_lipsync_routes.py +++ b/tests/unit/test_lipsync_routes.py @@ -298,6 +298,7 @@ class TestLipsyncServiceUnit: mock_db = MagicMock() svc = LipsyncService(mock_db, client=mock_mediakit) + svc.settings.use_gpu_lipsync = False with pytest.raises(MediaKitError, match="API 调用失败"): svc.create_job( @@ -473,6 +474,7 @@ class TestLipsyncServiceUnit: cosyvoice_service=mock_cosyvoice, voice_clone_repo=MagicMock(), ) + svc.settings.use_gpu_lipsync = False job = svc.create_job( user_id="user-1", video_url="https://example.com/video.mp4", @@ -616,12 +618,14 @@ class TestSignMediaUrl403Fix: def _svc(self, mock_mediakit, mock_cosyvoice): from app.services.lipsync_service import LipsyncService - return LipsyncService( + svc = LipsyncService( MagicMock(), client=mock_mediakit, cosyvoice_service=mock_cosyvoice, voice_clone_repo=MagicMock(), ) + svc.settings.use_gpu_lipsync = False + return svc def test_own_oss_unsigned_url_gets_resigned(self, mock_mediakit, mock_cosyvoice): """裸 public_url(不带签名,私有桶匿名 403)必须被重签."""