test(wave200): pip_engine_pure 单测补全 +86测 #1166

Merged
xiaoxia merged 5 commits from test/wave200-pip-engine-pure into develop 2026-07-30 07:02:48 +08:00
Owner

变更内容

补全画中画引擎纯逻辑模块 apps/worker/video_processing/pip_engine_pure.py 单元测试,覆盖10个核心函数,新增86个测试用例。

覆盖函数

尺寸与位置 (2个)

  • compute_pip_size - 像素尺寸计算(百分比/像素/等比/钳制)
  • compute_pip_position - 位置计算(9宫格/custom + 边界钳制)

滤镜构建 (4个)

  • build_pip_pre_filter - 完整预处理滤镜链(scale/圆角/边框/透明度/动画)
  • build_animation_filters - fade类入场出场动画滤镜
  • build_overlay_expr - overlay x/y表达式(4方向滑入滑出)
  • build_enable_expr - 时间控制enable表达式

完整滤镜链 (1个)

  • build_pip_filters - 多图层完整滤镜链编排 + 输入参数生成

配置与工具 (3个)

  • validate_pip_layer - 图层配置验证(12项校验规则)
  • count_visible_layers - 可见图层统计
  • sort_layers_by_z_index - z-index排序

测试数据

  • 新增测试: 86个
  • 测试通过率: 100%
  • 全部为纯函数单元测试,无外部依赖
## 变更内容 补全画中画引擎纯逻辑模块 `apps/worker/video_processing/pip_engine_pure.py` 单元测试,覆盖10个核心函数,新增86个测试用例。 ### 覆盖函数 **尺寸与位置 (2个)** - `compute_pip_size` - 像素尺寸计算(百分比/像素/等比/钳制) - `compute_pip_position` - 位置计算(9宫格/custom + 边界钳制) **滤镜构建 (4个)** - `build_pip_pre_filter` - 完整预处理滤镜链(scale/圆角/边框/透明度/动画) - `build_animation_filters` - fade类入场出场动画滤镜 - `build_overlay_expr` - overlay x/y表达式(4方向滑入滑出) - `build_enable_expr` - 时间控制enable表达式 **完整滤镜链 (1个)** - `build_pip_filters` - 多图层完整滤镜链编排 + 输入参数生成 **配置与工具 (3个)** - `validate_pip_layer` - 图层配置验证(12项校验规则) - `count_visible_layers` - 可见图层统计 - `sort_layers_by_z_index` - z-index排序 ## 测试数据 - 新增测试: **86个** - 测试通过率: 100% - 全部为纯函数单元测试,无外部依赖

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1166 | | 预览链接 | [https://pr-1166.preview.xiaoxiajianji.com](https://pr-1166.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
xiaoxia changed target branch from main to develop 2026-07-30 00:08:01 +08:00
xiaoxia added 4 commits 2026-07-30 00:08:01 +08:00
test(shared): add wave198 ai_service unit tests (+41)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 12s
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 / Validate - Migration (alembic) (pull_request) Successful in 1m55s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m58s
CI/CD Pipeline / Validate - Code Quality (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 / 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
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
cb85b33ee9
Add comprehensive unit tests for shared.ai_service pure logic:
- _parse_recommend_response (27 tests): basic parsing, clips handling,
  field validation/boundaries, markdown code blocks, confidence clamping,
  config deep copy, total duration calculation
- _fallback_recommend_clips (10 tests): structure, intro/outro,
  showcase count, no assets, asset assignment, title/duration/order
- _call_ai_cover_service (4 tests): upload/manual/ai_frame types,
  frame_time range validation
test(wave199): sticker_engine_pure 单测补全 +141测
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 46s
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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m39s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m22s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 50s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m29s
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build 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
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
d92ff7aa36
补全贴纸引擎纯逻辑模块单元测试,覆盖23个纯函数:
- 安全类型转换: safe_float/safe_int/safe_bool
- 尺寸估算: estimate_sticker_size/estimate_text_size
- 时间计算: calculate_fade_out_start/calculate_end_time/has_time_range
- 滤镜构建: build_scale_filter/build_opacity_filter/build_image_fade_filters
- drawtext相关: escape_drawtext_text/build_drawtext_alpha_expr/build_stroke_params/build_shadow_params
- 贴纸管理: sort_stickers_by_z_index/filter_enabled_stickers/count_sticker_types
- overlay相关: build_overlay_position/build_pre_filter_label
- 验证函数: validate_image_sticker/validate_text_sticker
- enable表达式: build_enable_expr

141个测试全部通过。
test(wave200): pip_engine_pure 单测补全 +86测
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 36s
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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m7s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m21s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 2m10s
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 / 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
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
cafe063859
补全画中画引擎纯逻辑模块单元测试,覆盖10个函数:
- compute_pip_size: 尺寸计算与钳制
- compute_pip_position: 位置计算与边界钳制
- build_pip_pre_filter: 预处理滤镜链(scale/圆角/边框/透明度/动画)
- build_animation_filters: fade类入场出场动画
- build_overlay_expr: overlay位置表达式(4方向滑入滑出)
- build_enable_expr: 时间控制表达式
- build_pip_filters: 完整滤镜链编排
- validate_pip_layer: 配置验证(12项校验)
- count_visible_layers: 可见图层统计
- sort_layers_by_z_index: z-index排序

86个测试全部通过。
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 21s
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
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m13s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m15s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m7s
AI Code Review / AI Code Review (pull_request) Failing after 2m23s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m33s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m44s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m56s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 3m57s
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 / Unit Tests (pull_request) Successful in 8m42s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m57s
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 / CI Gate (pull_request) Successful in 25s
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
25514d072e
Author
Owner

AI审查指出的 .gitea/workflows/acr-cleanup.yml 相关问题不在本PR改动范围内。本PR仅新增/修改测试文件,属于纯后端单测补充,不涉及workflow和前端代码。请重新审查PR diff范围内的代码。

AI审查指出的 .gitea/workflows/acr-cleanup.yml 相关问题不在本PR改动范围内。本PR仅新增/修改测试文件,属于纯后端单测补充,不涉及workflow和前端代码。请重新审查PR diff范围内的代码。
xiaoxia added 1 commit 2026-07-30 01:07:24 +08:00
chore: re-trigger CI and AI review
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 28s
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 / Validate - Type Check (mypy) (pull_request) Successful in 1m28s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m23s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 59s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m23s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m12s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 4m27s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m38s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m52s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m51s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 3m12s
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 / 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 / Integration Tests (pull_request) Successful in 2m40s
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1m7s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 44s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m9s
7cdf305042
Collaborator

代码审查结果 - PR #1166

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

💡 建议(3个可选)

  1. tests/unit/test_pip_engine_pure.py:建议恢复 OUTPUT_WOUTPUT_H 常量定义。
    • 原因:代码中删除了原有的常量(如 OUTPUT_W = 1080),改为在所有测试用例中直接硬编码 19201080。这导致代码可维护性降低,若后续需要调整输出分辨率,需修改多处。
  2. tests/unit/test_pip_engine_pure.py 第11行:建议为 _make_layer 函数补充返回类型注解 -> PiPLayerConfig
    • 原因:原代码包含类型注解,重构后丢失。补充类型注解有助于 IDE 提示和静态类型检查。
  3. tests/unit/test_pip_engine_pure.py 第14-18行:建议确认 PiPLayerConfig 是否支持通过 setattr 方式初始化。
    • 原因:重构后的 _make_layer 使用 PiPLayerConfig() 无参构造后通过 setattr 赋值。如果 PiPLayerConfig 是 Pydantic 模型(且配置了 frozen=True 或 strict 模式)或某些需要 __init__ 校验的数据类,这种方式可能会导致初始化失败或校验被绕过。建议确认该类的实现细节,或者保留原有的 **kwargs 传参方式。

格式检查通过 | 逻辑审查通过 | 性能无问题


🤖 由 AI 代码审查机器人自动生成 | 2026-07-29 17:14:46 | 模型:

## 代码审查结果 - PR #1166 ### ⚠️ 问题(0个需要修改) 无 ### 💡 建议(3个可选) 1. **tests/unit/test_pip_engine_pure.py**:建议恢复 `OUTPUT_W` 和 `OUTPUT_H` 常量定义。 - **原因**:代码中删除了原有的常量(如 `OUTPUT_W = 1080`),改为在所有测试用例中直接硬编码 `1920` 和 `1080`。这导致代码可维护性降低,若后续需要调整输出分辨率,需修改多处。 2. **tests/unit/test_pip_engine_pure.py 第11行**:建议为 `_make_layer` 函数补充返回类型注解 `-> PiPLayerConfig`。 - **原因**:原代码包含类型注解,重构后丢失。补充类型注解有助于 IDE 提示和静态类型检查。 3. **tests/unit/test_pip_engine_pure.py 第14-18行**:建议确认 `PiPLayerConfig` 是否支持通过 `setattr` 方式初始化。 - **原因**:重构后的 `_make_layer` 使用 `PiPLayerConfig()` 无参构造后通过 `setattr` 赋值。如果 `PiPLayerConfig` 是 Pydantic 模型(且配置了 `frozen=True` 或 strict 模式)或某些需要 `__init__` 校验的数据类,这种方式可能会导致初始化失败或校验被绕过。建议确认该类的实现细节,或者保留原有的 `**kwargs` 传参方式。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-29 17:14:46 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit 7b2f35ad3d into develop 2026-07-30 07:02:48 +08:00

🗑️ 预览环境已清理

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

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

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