test: P3-1 第49波单元测试(generated_video/duplication/tts_config/classification,+88) #837

Merged
xiaoxia merged 1 commits from test/wave49-domain-generatedvideo-duplication-ttsconfig-classification into develop 2026-07-24 18:58:18 +08:00
Owner

内容

新增4个领域模块的单元测试,合计 +88 个用例。

模块列表

  1. test_generated_video.py (14个) - GeneratedVideo 生成视频实体

    • create 正常创建 / 空格strip / 各字段空值校验
    • 默认值 / generation_params / ID唯一性
  2. test_duplication.py (36个) - 查重记录领域模型

    • DuplicateSegment 创建校验(时间范围/相似度边界)
    • DuplicationRecord 创建校验 + 状态流转
    • mark_processing / mark_completed / mark_failed
    • can_retry / reset_for_retry 重试逻辑
  3. test_tts_config.py (31个) - TTS 配音配置

    • 默认值 / parse 解析各种输入类型
    • enabled=False 短路返回
    • _clamp 边界钳制(speed/pitch/volume)
    • 类型转换(int→float)
  4. test_classification.py (7个) - 分类任务枚举与实体

    • AssetLibraryKind / IngestJobStatus / AssetClassification 枚举值
    • ClassificationJobStatus.missing 兼容(done/success/fail等)
    • ClassificationStatus 向后兼容别名
    • ClassificationJob.create 校验
## 内容 新增4个领域模块的单元测试,合计 +88 个用例。 ### 模块列表 1. **test_generated_video.py** (14个) - GeneratedVideo 生成视频实体 - create 正常创建 / 空格strip / 各字段空值校验 - 默认值 / generation_params / ID唯一性 2. **test_duplication.py** (36个) - 查重记录领域模型 - DuplicateSegment 创建校验(时间范围/相似度边界) - DuplicationRecord 创建校验 + 状态流转 - mark_processing / mark_completed / mark_failed - can_retry / reset_for_retry 重试逻辑 3. **test_tts_config.py** (31个) - TTS 配音配置 - 默认值 / parse 解析各种输入类型 - enabled=False 短路返回 - _clamp 边界钳制(speed/pitch/volume) - 类型转换(int→float) 4. **test_classification.py** (7个) - 分类任务枚举与实体 - AssetLibraryKind / IngestJobStatus / AssetClassification 枚举值 - ClassificationJobStatus._missing_ 兼容(done/success/fail等) - ClassificationStatus 向后兼容别名 - ClassificationJob.create 校验
xiaoxia added 1 commit 2026-07-24 18:11:08 +08:00
test: P3-1 第49波单元测试(generated_video/duplication/tts_config/classification,+88)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 5s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m45s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m11s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m14s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 34s
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 / PR Build Web Image (pull_request) Successful in 22s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 46s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 10s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m8s
AI Code Review / AI Code Review (pull_request) Successful in 4m52s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 6m44s
CI/CD Pipeline / Frontend Unit Tests (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 Staging (Watchtower auto-deploy) (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 / Integration Tests (pull_request) Successful in 3m36s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 4m30s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 14m0s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 7s
5210d1f396
新增4个领域模块单测:
- test_generated_video.py: GeneratedVideo生成视频实体(14个)
- test_duplication.py: 查重记录领域模型(36个)- DuplicateSegment校验 + DuplicationRecord状态流转/重试
- test_tts_config.py: TTS配音配置解析与边界钳制(31个)
- test_classification.py: 分类任务枚举与实体(7个)

合计 +88 个测试用例,全部通过。
Collaborator

代码审查结果 - PR #837

⚠️ 问题(0个需要修改)

💡 建议(3个可选)

  1. test_duplication.py 第288行:建议使用关键字参数调用 mark_completed

    • 具体内容:该处使用了位置参数 record2.mark_completed(10.0, 1, [seg]),而同一文件第263行使用了关键字参数。为了代码的可读性和防止参数顺序调整导致的Bug,建议统一使用关键字参数(如 duplicate_rate=10.0)。
  2. test_classification.py 第59行:确认 None 处理逻辑的实现

    • 具体内容:测试用例 test_none_fallback_to_pending 传入了 None 值。对于 Python 标准的 Enum 类型,传入 None 会抛出 TypeError。请确保 ClassificationJobStatus 的实现中(如 __new___missing_ 方法)显式处理了 None,否则该测试会导致运行时错误。
  3. test_generated_video.py:建议使用 Mock 或占位符 URL

    • 具体内容:测试中硬编码了 https://example.com 等外部 URL。虽然当前测试仅涉及领域模型创建,不发起网络请求,但使用 http://test-urlfile:// 等明显的占位符能更清晰地表明这是测试数据,避免产生对外部依赖的误解。

格式检查通过 | 逻辑审查通过 | 性能良好


🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 10:25:23 | 模型:

## 代码审查结果 - PR #837 ### ⚠️ 问题(0个需要修改) 无 ### 💡 建议(3个可选) 1. **test_duplication.py 第288行**:建议使用关键字参数调用 `mark_completed` - 具体内容:该处使用了位置参数 `record2.mark_completed(10.0, 1, [seg])`,而同一文件第263行使用了关键字参数。为了代码的可读性和防止参数顺序调整导致的Bug,建议统一使用关键字参数(如 `duplicate_rate=10.0`)。 2. **test_classification.py 第59行**:确认 `None` 处理逻辑的实现 - 具体内容:测试用例 `test_none_fallback_to_pending` 传入了 `None` 值。对于 Python 标准的 `Enum` 类型,传入 `None` 会抛出 `TypeError`。请确保 `ClassificationJobStatus` 的实现中(如 `__new__` 或 `_missing_` 方法)显式处理了 `None`,否则该测试会导致运行时错误。 3. **test_generated_video.py**:建议使用 Mock 或占位符 URL - 具体内容:测试中硬编码了 `https://example.com` 等外部 URL。虽然当前测试仅涉及领域模型创建,不发起网络请求,但使用 `http://test-url` 或 `file://` 等明显的占位符能更清晰地表明这是测试数据,避免产生对外部依赖的误解。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能良好 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 10:25:23 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit e38f13eb96 into develop 2026-07-24 18:58:18 +08:00
xiaoxia deleted branch test/wave49-domain-generatedvideo-duplication-ttsconfig-classification 2026-07-24 18:58:18 +08:00

🗑️ 预览环境已清理

PR #837 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #837 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.