test(wave155): generated_video生成视频实体单测 +16 #1084

Merged
xiaoxia merged 5 commits from test/wave155-generated-video into develop 2026-07-28 16:19:01 +08:00
Owner

概述

为 domain/generated_video.py 新增 16 个单测,纯逻辑 0 外部依赖。

覆盖范围

  • create 必填字段 + 默认值
  • strip 行为(4个字符串字段)
  • 空值校验(project_id/generation_task_id/name/file_url)
  • 唯一ID + 时间戳
  • 零值合法(宽高/fps)
  • generation_params 独立性

验证

  • ruff: All checks passed
  • pytest: 16 passed
## 概述 为 domain/generated_video.py 新增 16 个单测,纯逻辑 0 外部依赖。 ## 覆盖范围 - create 必填字段 + 默认值 - strip 行为(4个字符串字段) - 空值校验(project_id/generation_task_id/name/file_url) - 唯一ID + 时间戳 - 零值合法(宽高/fps) - generation_params 独立性 ## 验证 - ruff: All checks passed - pytest: 16 passed
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:1 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

  1. [test_classification.py, test_duplication.py] 测试异常处理方式
    • 具体内容:代码中多处使用了 try...except assert False 的模式来测试异常(如 test_create_empty_project_id)。虽然逻辑正确,但建议使用 pytest 推荐的 pytest.raises(ValueError) 上下文管理器。这样代码更简洁,且能明确指定捕获的异常类型,避免意外捕获其他非预期异常。
    • 示例:
      # 当前写法
      try:
          ClassificationJob.create(project_id="", asset_id="a1")
          assert False
      except ValueError as e:
          assert "project_id" in str(e)
      
      # 建议写法
      with pytest.raises(ValueError, match="project_id"):
          ClassificationJob.create(project_id="", asset_id="a1")
      

良好实践

  1. 边界条件覆盖全面:测试用例不仅覆盖了正常流程,还详细测试了空字符串、纯空白字符串、负数、零值、边界值(如 0 和 100 的相似度)等场景,体现了较高的测试覆盖率。
  2. 独立性测试test_create_unique_idtest_segments_independent_list 等用例验证了对象间的独立性,这是 Domain Model 测试中的良好实践。
  3. 状态流转验证:在 test_duplication.py 中,对 DuplicationRecord 的状态流转(Pending -> Processing -> Completed/Failed)以及重置逻辑进行了完整的闭环测试,确保了业务逻辑的健壮性。
  4. 代码结构清晰:测试类和方法命名规范,能够直观反映测试意图,符合 Python 测试的最佳实践。

注:本次审查仅针对 Diff 中提供的 test_classification.pytest_duplication.py 部分内容,其余 3 个文件因 Diff 截断未包含在审查范围内。


🤖 由 AI 代码审查机器人自动生成 | 2026-07-28 06:43:51 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:1 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 1. **[test_classification.py, test_duplication.py] 测试异常处理方式** - 具体内容:代码中多处使用了 `try...except assert False` 的模式来测试异常(如 `test_create_empty_project_id`)。虽然逻辑正确,但建议使用 pytest 推荐的 `pytest.raises(ValueError)` 上下文管理器。这样代码更简洁,且能明确指定捕获的异常类型,避免意外捕获其他非预期异常。 - 示例: ```python # 当前写法 try: ClassificationJob.create(project_id="", asset_id="a1") assert False except ValueError as e: assert "project_id" in str(e) # 建议写法 with pytest.raises(ValueError, match="project_id"): ClassificationJob.create(project_id="", asset_id="a1") ``` ### ✅ 良好实践 1. **边界条件覆盖全面**:测试用例不仅覆盖了正常流程,还详细测试了空字符串、纯空白字符串、负数、零值、边界值(如 0 和 100 的相似度)等场景,体现了较高的测试覆盖率。 2. **独立性测试**:`test_create_unique_id` 和 `test_segments_independent_list` 等用例验证了对象间的独立性,这是 Domain Model 测试中的良好实践。 3. **状态流转验证**:在 `test_duplication.py` 中,对 `DuplicationRecord` 的状态流转(Pending -> Processing -> Completed/Failed)以及重置逻辑进行了完整的闭环测试,确保了业务逻辑的健壮性。 4. **代码结构清晰**:测试类和方法命名规范,能够直观反映测试意图,符合 Python 测试的最佳实践。 --- *注:本次审查仅针对 Diff 中提供的 `test_classification.py` 和 `test_duplication.py` 部分内容,其余 3 个文件因 Diff 截断未包含在审查范围内。* --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-28 06:43:51 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia changed target branch from main to develop 2026-07-28 16:09:24 +08:00
xiaoxia added 2 commits 2026-07-28 16:12:09 +08:00
为 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个
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
ce31922257
为 domain/duplication.py 新增 40 个单测,纯逻辑 0 外部依赖:

- DuplicateSegment.create 工厂/校验:10个
- DuplicationRecord.create 工厂/校验:11个
- 状态流转 (pending/processing/completed/failed):13个
- can_retry + reset_for_retry:4个
- segments 列表:3个
xiaoxia force-pushed test/wave155-generated-video from 94fb5fb299 to ce31922257 2026-07-28 16:12:09 +08:00 Compare
xiaoxia added 3 commits 2026-07-28 16:13:52 +08:00
为 domain/edit_plan_clip.py 新增 44 个单测,纯逻辑 0 外部依赖:

- EditPlanClipStatus 枚举:7个
- create 工厂/校验:17个
- assign_asset 素材分配:5个
- 状态流转(pending→ready→rendered/failed):8个
- end_time/has_asset 属性:7个
为 domain/classification.py 新增 34 个单测:

- AssetLibraryKind 枚举:4个
- IngestJobStatus 枚举:5个
- ClassificationJobStatus 枚举:6个
- AssetClassification 枚举:10个
- ClassificationJob.create:9个
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
ea5987ee88
为 domain/generated_video.py 新增 16 个单测:

- create 必填字段 + 默认值
- strip 行为
- 4个空值校验(project_id/task_id/name/file_url)
- 唯一ID + 时间戳
- 零值合法(宽高/fps)
- generation_params 独立性
xiaoxia merged commit ccfaf9aa7e into develop 2026-07-28 16:19:01 +08:00
Sign in to join this conversation.