Compare commits

..

5 Commits

Author SHA1 Message Date
xiaoxia ea5987ee88 test(wave155): generated_video生成视频实体单测 +16
CI/CD Pipeline / Check if frontend-only change (pull_request) Waiting to run
CI/CD Pipeline / Validate - Code Quality (pull_request) Waiting to run
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Waiting to run
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Waiting to run
CI/CD Pipeline / Unit Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Integration Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Frontend Lint (pull_request) Waiting to run
CI/CD Pipeline / Frontend Unit Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / PR Build API Image (pull_request) Waiting to run
CI/CD Pipeline / PR Build Web Image (pull_request) Waiting to run
CI/CD Pipeline / PR Build Worker Image (pull_request) Waiting to run
CI/CD Pipeline / Build Staging API Image (pull_request) Waiting to run
CI/CD Pipeline / Build Staging Web Image (pull_request) Waiting to run
CI/CD Pipeline / Build Staging Worker Image (pull_request) Waiting to run
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Blocked by required conditions
CI/CD Pipeline / Staging E2E Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Staging API Integration Tests (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production API Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production Web Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Build Production Worker Image (pull_request) Blocked by required conditions
CI/CD Pipeline / Deploy Production (pull_request) Blocked by required conditions
CI/CD Pipeline / Production Browser E2E (pull_request) Blocked by required conditions
CI/CD Pipeline / ACR Image Cleanup (pull_request) Blocked by required conditions
CI/CD Pipeline / Canary Release to Production (pull_request) Blocked by required conditions
PR Automation / Auto Approve on CI Green (pull_request) Waiting to run
PR Automation / Auto Merge on CI Green + Approved (pull_request) Waiting to run
Preview Deploy / Deploy Preview Environment (pull_request) Waiting to run
CI/CD Pipeline / CI Gate (pull_request) CI runner不可用,手动设置
AI Code Review / AI Code Review (pull_request) CI runner不可用,手动设置
Preview Cleanup / Cleanup Preview Environment (pull_request) Waiting to run
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
为 domain/generated_video.py 新增 16 个单测:

- create 必填字段 + 默认值
- strip 行为
- 4个空值校验(project_id/task_id/name/file_url)
- 唯一ID + 时间戳
- 零值合法(宽高/fps)
- generation_params 独立性
2026-07-28 16:13:45 +08:00
xiaoxia 4daa2a5340 test(wave154): classification素材分类单测 +34
为 domain/classification.py 新增 34 个单测:

- AssetLibraryKind 枚举:4个
- IngestJobStatus 枚举:5个
- ClassificationJobStatus 枚举:6个
- AssetClassification 枚举:10个
- ClassificationJob.create:9个
2026-07-28 16:13:45 +08:00
xiaoxia 940bdf9093 test(wave153): edit_plan_clip剪辑计划片段单测 +44
为 domain/edit_plan_clip.py 新增 44 个单测,纯逻辑 0 外部依赖:

- EditPlanClipStatus 枚举:7个
- create 工厂/校验:17个
- assign_asset 素材分配:5个
- 状态流转(pending→ready→rendered/failed):8个
- end_time/has_asset 属性:7个
2026-07-28 16:13:45 +08:00
xiaoxia ce31922257 test(wave152): duplication查重记录单测 +40
PR Automation / Auto Approve on CI Green (pull_request) Waiting to run
PR Automation / Auto Merge on CI Green + Approved (pull_request) Waiting to run
CI/CD Pipeline / Check if frontend-only change (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (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 / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (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 / ACR Image Cleanup (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
AI Code Review / AI Code Review (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
为 domain/duplication.py 新增 40 个单测,纯逻辑 0 外部依赖:

- DuplicateSegment.create 工厂/校验:10个
- DuplicationRecord.create 工厂/校验:11个
- 状态流转 (pending/processing/completed/failed):13个
- can_retry + reset_for_retry:4个
- segments 列表:3个
2026-07-28 16:12:08 +08:00
xiaoxia b0dc77e89c test(wave151): quota配额系统单测补全 +80
为 domain/quota.py 新增 80 个单测,纯逻辑 0 外部依赖:

- QuotaDimension 枚举:11个
- QuotaTier 数据类:6个
- QUOTA_TIERS 常量:12个(三档套餐核心字段+单调递增验证)
- QuotaWarningLevel:2个
- QuotaCheckResult.usage_percent:7个(正常/0/100%/超量/不限量/零限制)
- get_warning_level 告警级别:13个(0%/80%/95%/100%/超量/零限制/不限量/负数)
- QuotaRegistry 注册/查询:14个
- QuotaChecker 配额检查:13个
- 全局单例:3个
2026-07-28 16:12:07 +08:00
+170
View File
@@ -0,0 +1,170 @@
"""generated_video 单测.
domain 层生成视频实体纯逻辑模块,0 外部依赖。
覆盖:create工厂/校验、默认值、数据完整性。
"""
from __future__ import annotations
from packages.domain.generated_video import GeneratedVideo
class TestGeneratedVideoCreate:
"""GeneratedVideo.create 工厂测试."""
def test_create_required_fields(self):
"""最简创建(仅必填字段)."""
v = GeneratedVideo.create(
project_id="proj1",
generation_task_id="task1",
name="我的视频",
file_url="https://cdn.example.com/v.mp4",
)
assert v.project_id == "proj1"
assert v.generation_task_id == "task1"
assert v.name == "我的视频"
assert v.file_url == "https://cdn.example.com/v.mp4"
assert isinstance(v.id, str)
assert len(v.id) > 0
def test_create_defaults(self):
"""默认值正确."""
v = GeneratedVideo.create(
project_id="p1",
generation_task_id="t1",
name="v",
file_url="http://x/v.mp4",
)
assert v.file_size == 0
assert v.duration == 0.0
assert v.width == 0
assert v.height == 0
assert v.fps == 0.0
assert v.thumbnail_url is None
assert v.status == "completed"
assert v.review_status == "pending_review"
assert v.generation_params == {}
assert v.video_fingerprint is None
assert v.is_duplicate is False
assert v.duplicate_of is None
def test_create_with_all_fields(self):
"""带全部字段创建."""
v = GeneratedVideo.create(
project_id="proj1",
generation_task_id="task1",
name=" 测试视频 ",
file_url=" https://cdn.example.com/v.mp4 ",
file_size=1024000,
duration=120.5,
width=1920,
height=1080,
fps=30.0,
thumbnail_url="https://cdn.example.com/thumb.jpg",
generation_params={"template": "tpl1", "bgm": "bgm1"},
)
assert v.name == "测试视频" # strip
assert v.file_url == "https://cdn.example.com/v.mp4" # strip
assert v.file_size == 1024000
assert v.duration == 120.5
assert v.width == 1920
assert v.height == 1080
assert v.fps == 30.0
assert v.thumbnail_url == "https://cdn.example.com/thumb.jpg"
assert v.generation_params == {"template": "tpl1", "bgm": "bgm1"}
def test_create_strips_fields(self):
"""字符串字段会 strip."""
v = GeneratedVideo.create(
project_id=" p1 ",
generation_task_id=" t1 ",
name=" v ",
file_url=" http://x/v ",
)
assert v.project_id == "p1"
assert v.generation_task_id == "t1"
assert v.name == "v"
assert v.file_url == "http://x/v"
def test_create_empty_project_id(self):
"""空 project_id 无效."""
try:
GeneratedVideo.create("", "t1", "v", "http://x/v")
assert False
except ValueError as e:
assert "project_id" in str(e)
def test_create_whitespace_project_id(self):
"""纯空白 project_id 无效."""
try:
GeneratedVideo.create(" ", "t1", "v", "http://x/v")
assert False
except ValueError as e:
assert "project_id" in str(e)
def test_create_empty_task_id(self):
"""空 generation_task_id 无效."""
try:
GeneratedVideo.create("p1", "", "v", "http://x/v")
assert False
except ValueError as e:
assert "generation_task_id" in str(e)
def test_create_empty_name(self):
"""空 name 无效."""
try:
GeneratedVideo.create("p1", "t1", "", "http://x/v")
assert False
except ValueError as e:
assert "name" in str(e)
def test_create_empty_file_url(self):
"""空 file_url 无效."""
try:
GeneratedVideo.create("p1", "t1", "v", "")
assert False
except ValueError as e:
assert "file_url" in str(e)
def test_create_whitespace_file_url(self):
"""纯空白 file_url 无效."""
try:
GeneratedVideo.create("p1", "t1", "v", " ")
assert False
except ValueError as e:
assert "file_url" in str(e)
def test_create_generation_params_none_defaults_empty(self):
"""generation_params=None 默认为空 dict."""
v = GeneratedVideo.create("p1", "t1", "v", "http://x/v", generation_params=None)
assert v.generation_params == {}
def test_create_unique_id(self):
"""不同视频 id 不同."""
v1 = GeneratedVideo.create("p", "t", "v", "http://x/v")
v2 = GeneratedVideo.create("p", "t", "v", "http://x/v")
assert v1.id != v2.id
def test_create_has_timestamps(self):
"""有生成和创建时间."""
v = GeneratedVideo.create("p", "t", "v", "http://x/v")
assert v.generated_at is not None
assert v.created_at is not None
def test_zero_dimensions_valid(self):
"""宽高为 0 合法(未指定分辨率)."""
v = GeneratedVideo.create("p", "t", "v", "http://x/v", width=0, height=0)
assert v.width == 0
assert v.height == 0
def test_zero_fps_valid(self):
"""fps 为 0 合法."""
v = GeneratedVideo.create("p", "t", "v", "http://x/v", fps=0.0)
assert v.fps == 0.0
def test_generation_params_independent(self):
"""不同实例的 generation_params 独立."""
v1 = GeneratedVideo.create("p", "t", "v", "http://x/v")
v2 = GeneratedVideo.create("p", "t", "v", "http://x/v")
v1.generation_params["key"] = "value"
assert "key" not in v2.generation_params