d21b16aac7
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web 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 / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (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 / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 13s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 47s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 37s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 2m10s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m18s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m39s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m3s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 20s
AI Code Review / AI Code Review (pull_request) Successful in 7m16s
- preset_voices: 22个 - 数据类属性/默认值/frozen不可变/to_dict序列化/预置列表/按ID查询/8音色参数化 - template: 20个 - TemplateSegment/Template/TemplateCategory 三类实体完整覆盖 - template_version: 12个 - 创建工厂/默认值/config与clip_configs空值处理/完整字段/slots约束 已rebase到最新develop(含第四波),解决合并冲突
128 lines
4.1 KiB
Python
128 lines
4.1 KiB
Python
"""
|
|
EditTemplateVersion 模板版本领域模型单元测试
|
|
"""
|
|
|
|
import pytest
|
|
from domain.template_version import EditTemplateVersion
|
|
|
|
|
|
class TestEditTemplateVersionCreate:
|
|
"""创建模板版本测试"""
|
|
|
|
def test_create_required_fields(self):
|
|
v = EditTemplateVersion.create(template_id="tpl-1", version=1)
|
|
assert v.id is not None
|
|
assert len(v.id) == 32
|
|
assert v.template_id == "tpl-1"
|
|
assert v.version == 1
|
|
|
|
def test_default_values(self):
|
|
v = EditTemplateVersion.create(template_id="tpl-1", version=1)
|
|
assert v.name == ""
|
|
assert v.editing_mode == "one_take"
|
|
assert v.config == {}
|
|
assert v.clip_configs == []
|
|
assert v.change_note == ""
|
|
assert v.published_by == ""
|
|
|
|
def test_with_name_and_mode(self):
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-1",
|
|
version=2,
|
|
name="风景Vlog模板",
|
|
editing_mode="voice_over",
|
|
)
|
|
assert v.name == "风景Vlog模板"
|
|
assert v.editing_mode == "voice_over"
|
|
|
|
def test_with_config(self):
|
|
config = {
|
|
"title": {"font_size": 24},
|
|
"subtitle": {"style": "bottom"},
|
|
"bgm": {"volume": 0.5},
|
|
}
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-1",
|
|
version=1,
|
|
config=config,
|
|
)
|
|
assert v.config == config
|
|
assert v.config["title"]["font_size"] == 24
|
|
|
|
def test_with_clip_configs(self):
|
|
clips = [
|
|
{"clip_id": 1, "duration": 3.0, "transition": "fade"},
|
|
{"clip_id": 2, "duration": 5.0, "transition": "slide"},
|
|
]
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-1",
|
|
version=1,
|
|
clip_configs=clips,
|
|
)
|
|
assert len(v.clip_configs) == 2
|
|
assert v.clip_configs[0]["clip_id"] == 1
|
|
|
|
def test_config_none_defaults_to_empty_dict(self):
|
|
v = EditTemplateVersion.create(template_id="tpl-1", version=1, config=None)
|
|
assert v.config == {}
|
|
|
|
def test_clip_configs_none_defaults_to_empty_list(self):
|
|
v = EditTemplateVersion.create(template_id="tpl-1", version=1, clip_configs=None)
|
|
assert v.clip_configs == []
|
|
|
|
def test_with_change_note(self):
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-1",
|
|
version=3,
|
|
change_note="优化转场效果,新增滤镜",
|
|
)
|
|
assert v.change_note == "优化转场效果,新增滤镜"
|
|
|
|
def test_with_published_by(self):
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-1",
|
|
version=1,
|
|
published_by="user-123",
|
|
)
|
|
assert v.published_by == "user-123"
|
|
|
|
def test_full_version(self):
|
|
config = {"bgm": {"volume": 0.3}}
|
|
clips = [{"clip_id": 1, "duration": 2.5}]
|
|
v = EditTemplateVersion.create(
|
|
template_id="tpl-abc",
|
|
version=5,
|
|
name="正式版v5",
|
|
editing_mode="one_take",
|
|
config=config,
|
|
clip_configs=clips,
|
|
change_note="第五次发布",
|
|
published_by="admin",
|
|
)
|
|
assert v.template_id == "tpl-abc"
|
|
assert v.version == 5
|
|
assert v.name == "正式版v5"
|
|
assert v.editing_mode == "one_take"
|
|
assert v.config == config
|
|
assert v.clip_configs == clips
|
|
assert v.change_note == "第五次发布"
|
|
assert v.published_by == "admin"
|
|
|
|
def test_version_number(self):
|
|
for ver in [1, 2, 5, 10, 99]:
|
|
v = EditTemplateVersion.create(template_id="t1", version=ver)
|
|
assert v.version == ver
|
|
|
|
def test_has_created_at(self):
|
|
v = EditTemplateVersion.create(template_id="t1", version=1)
|
|
assert v.created_at is not None
|
|
|
|
|
|
class TestEditTemplateVersionSlots:
|
|
"""slots 模式属性测试"""
|
|
|
|
def test_cannot_add_new_attribute(self):
|
|
v = EditTemplateVersion.create(template_id="t1", version=1)
|
|
with pytest.raises(AttributeError):
|
|
v.nonexistent_field = "value" # type: ignore[attr-defined]
|