68e41f6173
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 40s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 43s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 55s
AI Code Review / AI Code Review (pull_request) Successful in 1m12s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m23s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m52s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
根因:预览生成接口(POST /preview)硬编码 voice_library_id="", 导致用户选择的上传音频从未传递给 Worker,渲染时没有音频可混入。 修复: - CreatePreviewGenerationTaskRequest 增加 voice_library_id 字段 - 预览端点将 request.voice_library_id 透传给 CreateGenerationTaskCommand - 确认生成接口已自动继承源预览任务的 voice_library_id - 新增 4 个单元测试验证 schema 字段 下游链路(Worker 下载音频 → 渲染引擎混音)无需修改, 只需前端在创建预览任务时传入 voice_library_id 即可。
75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
"""预览生成 voice_library_id 透传修复测试.
|
|
|
|
Bug: 预览生成接口硬编码 voice_library_id="",导致用户选择的上传音频
|
|
在预览渲染时从未下载和混入,预览视频无声。
|
|
|
|
Fix: CreatePreviewGenerationTaskRequest 增加 voice_library_id 字段,
|
|
预览端点透传 request.voice_library_id。
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
os.environ.setdefault("JWT_SECRET_KEY", "unit-test-secret-key-for-testing")
|
|
os.environ.setdefault("DATABASE_URL", "sqlite:///test.db")
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "apps" / "api"))
|
|
|
|
|
|
class TestPreviewVoiceLibraryIdSchema:
|
|
"""CreatePreviewGenerationTaskRequest voice_library_id 字段测试."""
|
|
|
|
def test_default_empty_string(self):
|
|
"""不传 voice_library_id 时默认为空字符串."""
|
|
from app.schemas.generation_task import CreatePreviewGenerationTaskRequest
|
|
|
|
req = CreatePreviewGenerationTaskRequest(
|
|
template_id="tmpl_1",
|
|
asset_ids=["a1"],
|
|
)
|
|
assert req.voice_library_id == ""
|
|
|
|
def test_accepts_voice_library_id(self):
|
|
"""传入 voice_library_id 正常接收."""
|
|
from app.schemas.generation_task import CreatePreviewGenerationTaskRequest
|
|
|
|
req = CreatePreviewGenerationTaskRequest(
|
|
template_id="tmpl_1",
|
|
asset_ids=["a1"],
|
|
voice_library_id="asset_abc123",
|
|
)
|
|
assert req.voice_library_id == "asset_abc123"
|
|
|
|
def test_accepts_empty_voice_library_id(self):
|
|
"""显式传空字符串也正常."""
|
|
from app.schemas.generation_task import CreatePreviewGenerationTaskRequest
|
|
|
|
req = CreatePreviewGenerationTaskRequest(
|
|
template_id="tmpl_1",
|
|
asset_ids=["a1"],
|
|
voice_library_id="",
|
|
)
|
|
assert req.voice_library_id == ""
|
|
|
|
def test_all_fields_including_voice_library_id(self):
|
|
"""包含 voice_library_id 的完整请求."""
|
|
from app.schemas.generation_task import CreatePreviewGenerationTaskRequest
|
|
|
|
req = CreatePreviewGenerationTaskRequest(
|
|
template_id="tmpl_123",
|
|
asset_ids=["a1", "a2"],
|
|
title_ids=["t1"],
|
|
voice_ids=["v1"],
|
|
voice_library_id="voice_asset_456",
|
|
video_title="测试预览",
|
|
duration=30.0,
|
|
video_ratio="9:16",
|
|
bgm_config={"enabled": True, "volume": 0.5},
|
|
)
|
|
assert req.voice_library_id == "voice_asset_456"
|
|
assert req.asset_ids == ["a1", "a2"]
|
|
assert req.bgm_config["enabled"] is True
|