test(wave99): 35 unit tests for 8 small domain modules (cleanup) #962

Closed
xiaoxia wants to merge 0 commits from test/wave99-small-domain-modules into develop
Owner

变更内容

  • 新增 35 个单元测试,一次性清理 8 个零测试的小 domain 模块

覆盖模块

  • EditingMode 枚举 (4 tests)
  • TemplateSegment (2 tests)
  • ClipType + TransitionEffect 枚举 (3 tests)
  • TemplateClipConfig (11 tests): create 校验 + 时长范围属性 + 转场效果
  • EditTemplateVersion (6 tests): create + config/clip_configs 默认值
  • VoiceLibraryItem (2 tests): 构造 + 全字段
  • TitleLibraryItem (4 tests): 构造 + 分类 + is_active + usage_count
  • RecipeItem (3 tests): 构造 + 位置/元数据 + 类型多样性

测试结果

本地 35 passed

## 变更内容 - 新增 35 个单元测试,一次性清理 8 个零测试的小 domain 模块 ## 覆盖模块 - **EditingMode 枚举** (4 tests) - **TemplateSegment** (2 tests) - **ClipType + TransitionEffect 枚举** (3 tests) - **TemplateClipConfig** (11 tests): create 校验 + 时长范围属性 + 转场效果 - **EditTemplateVersion** (6 tests): create + config/clip_configs 默认值 - **VoiceLibraryItem** (2 tests): 构造 + 全字段 - **TitleLibraryItem** (4 tests): 构造 + 分类 + is_active + usage_count - **RecipeItem** (3 tests): 构造 + 位置/元数据 + 类型多样性 ## 测试结果 本地 35 passed
xiaoxia force-pushed test/wave99-small-domain-modules from 347cae8bd8 to de35710bf9 2026-07-26 20:12:44 +08:00 Compare

🚀 预览环境已部署

项目 详情
PR号 #962
预览链接 https://pr-962.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #962 | | 预览链接 | [https://pr-962.preview.xiaoxiajianji.com](https://pr-962.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
Collaborator

代码审查结果 - PR #962

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

  1. packages/domain/media_validation.py 第110行:视频时长校验逻辑存在缺陷,未处理 NaN(非数字)情况。

    • 说明:代码中 duration <= 0 用于判断视频是否有效。如果 ffprobe 返回的时长为 NaN(例如某些损坏文件或流媒体),Python 中 float('nan') <= 0 结果为 False,导致该损坏视频被错误判定为有效(True)。相比之下,音频校验使用 duration > 0NaN 会被正确判定为无效。这种不一致性会导致损坏的视频文件通过校验进入后续处理流程。
    • 后果:损坏或元数据异常的视频文件可能被系统接受,导致后续渲染或转码任务失败。
    • 建议:引入 math 模块,在校验前增加 math.isfinite(duration) 检查,确保时长是有效的有限数值。
  2. packages/domain/media_validation.py 第91行safe_parse_fps 函数对 None 输入缺乏防御性。

    • 说明:函数签名虽标注为 str,但在 Python 运行时若传入 None(例如 ffprobe 元数据中缺少帧率字段且未提供默认值时),执行 "/" in fps_str 会直接抛出 TypeError
    • 后果:当处理元数据不完整的文件时,Worker 任务可能因未捕获的异常而崩溃。
    • 建议:在函数入口处增加 if not fps_str: return 0.0 的类型检查或空值检查。

💡 建议(1个可选)

  1. packages/domain/media_validation.py 第119行:移除了非白名单视频编码的日志记录,降低了可观测性。
    • 说明:原代码在 ingest.py 中检测到非白名单编码时会记录 logger.info,新代码将其移除并注释“调用方负责日志”,但 ingest.py 中的调用方并未补充该日志。
    • 建议:建议在 is_valid_media 中使用 logging 模块记录该情况,或者确保 ingest.py 中的调用方在函数返回后补充日志记录,以便排查非标准编码格式的问题。

格式检查通过 | 逻辑审查需修改 | 性能无明显问题


🤖 由 AI 代码审查机器人自动生成 | 2026-07-26 12:27:23 | 模型:

## 代码审查结果 - PR #962 ### ⚠️ 问题(2个需要修改) 1. **packages/domain/media_validation.py 第110行**:视频时长校验逻辑存在缺陷,未处理 `NaN`(非数字)情况。 - **说明**:代码中 `duration <= 0` 用于判断视频是否有效。如果 `ffprobe` 返回的时长为 `NaN`(例如某些损坏文件或流媒体),Python 中 `float('nan') <= 0` 结果为 `False`,导致该损坏视频被错误判定为有效(`True`)。相比之下,音频校验使用 `duration > 0`,`NaN` 会被正确判定为无效。这种不一致性会导致损坏的视频文件通过校验进入后续处理流程。 - **后果**:损坏或元数据异常的视频文件可能被系统接受,导致后续渲染或转码任务失败。 - **建议**:引入 `math` 模块,在校验前增加 `math.isfinite(duration)` 检查,确保时长是有效的有限数值。 2. **packages/domain/media_validation.py 第91行**:`safe_parse_fps` 函数对 `None` 输入缺乏防御性。 - **说明**:函数签名虽标注为 `str`,但在 Python 运行时若传入 `None`(例如 `ffprobe` 元数据中缺少帧率字段且未提供默认值时),执行 `"/" in fps_str` 会直接抛出 `TypeError`。 - **后果**:当处理元数据不完整的文件时,Worker 任务可能因未捕获的异常而崩溃。 - **建议**:在函数入口处增加 `if not fps_str: return 0.0` 的类型检查或空值检查。 ### 💡 建议(1个可选) 1. **packages/domain/media_validation.py 第119行**:移除了非白名单视频编码的日志记录,降低了可观测性。 - **说明**:原代码在 `ingest.py` 中检测到非白名单编码时会记录 `logger.info`,新代码将其移除并注释“调用方负责日志”,但 `ingest.py` 中的调用方并未补充该日志。 - **建议**:建议在 `is_valid_media` 中使用 `logging` 模块记录该情况,或者确保 `ingest.py` 中的调用方在函数返回后补充日志记录,以便排查非标准编码格式的问题。 --- ✅ 格式检查通过 | ❌ 逻辑审查需修改 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-26 12:27:23 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia force-pushed test/wave99-small-domain-modules from de35710bf9 to 5289e427e2 2026-07-27 19:05:09 +08:00 Compare
xiaoxia closed this pull request 2026-07-27 19:49:03 +08:00

🗑️ 预览环境已清理

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

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

🗑️ **预览环境已清理** PR #962 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Check if frontend-only change (push) Has been cancelled
CI/CD Pipeline / Validate - Code Quality (push) Has been cancelled
CI/CD Pipeline / Validate - Type Check (mypy) (push) Has been cancelled
CI/CD Pipeline / Validate - Migration (alembic) (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Frontend Lint (push) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (push) Has been cancelled
CI/CD Pipeline / PR Build API Image (push) Has been cancelled
CI/CD Pipeline / PR Build Web Image (push) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (push) Has been cancelled
CI/CD Pipeline / Build Staging API Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Web Image (push) Has been cancelled
CI/CD Pipeline / Build Staging Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (push) Has been cancelled
CI/CD Pipeline / Canary Release to Production (push) Has been cancelled
CI/CD Pipeline / CI Gate (push) Has been cancelled
AI Code Review / AI Code Review (pull_request) Failing after 0s
PR Automation / Auto Approve on CI Green (pull_request) Failing after 0s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Failing after 0s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Failing after 0s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m33s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 48s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Failing after 1s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 0s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Failing after 1s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Failing after 0s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 0s
CI/CD Pipeline / Integration Tests (pull_request) Failing after 0s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 0s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Failing after 0s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 10m44s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 1m58s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m54s
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 / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration 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 Production (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Failing after 0s

Pull request closed

Sign in to join this conversation.