test(wave199): sticker_engine_pure 单测补全 +141测 #1165

Merged
xiaoxia merged 3 commits from test/wave199-sticker-engine-pure into develop 2026-07-30 00:25:31 +08:00
Owner

变更内容

补全贴纸引擎纯逻辑模块 apps/worker/video_processing/sticker_engine_pure.py 单元测试,覆盖23个纯函数,新增141个测试用例。

覆盖函数

安全类型转换 (3个)

  • safe_float - 安全float转换,含NaN检查
  • safe_int - 安全int转换
  • safe_bool - 安全bool转换,支持字符串变体

尺寸估算 (2个)

  • estimate_sticker_size - 贴纸尺寸估算
  • estimate_text_size - 文字贴纸尺寸估算

时间计算 (3个)

  • calculate_fade_out_start - 淡出开始时间计算
  • calculate_end_time - 结束时间计算
  • has_time_range - 是否有时间范围

滤镜构建 (4个)

  • build_scale_filter - 缩放滤镜构建
  • build_opacity_filter - 透明度滤镜构建
  • build_image_fade_filters - 图片淡入淡出滤镜
  • build_enable_expr - enable表达式构建

drawtext相关 (4个)

  • escape_drawtext_text - 特殊字符转义
  • build_drawtext_alpha_expr - alpha淡入淡出表达式
  • build_stroke_params - 描边参数
  • build_shadow_params - 阴影参数

贴纸管理 (3个)

  • sort_stickers_by_z_index - z-index排序
  • filter_enabled_stickers - 启用过滤
  • count_sticker_types - 类型统计

overlay相关 (2个)

  • build_overlay_position - 位置参数构建
  • build_pre_filter_label - 预处理标签构建

验证函数 (2个)

  • validate_image_sticker - 图片贴纸验证
  • validate_text_sticker - 文字贴纸验证

测试数据

  • 新增测试: 141个
  • 测试通过率: 100%
  • 全部为纯函数单元测试,无外部依赖
## 变更内容 补全贴纸引擎纯逻辑模块 `apps/worker/video_processing/sticker_engine_pure.py` 单元测试,覆盖23个纯函数,新增141个测试用例。 ### 覆盖函数 **安全类型转换 (3个)** - `safe_float` - 安全float转换,含NaN检查 - `safe_int` - 安全int转换 - `safe_bool` - 安全bool转换,支持字符串变体 **尺寸估算 (2个)** - `estimate_sticker_size` - 贴纸尺寸估算 - `estimate_text_size` - 文字贴纸尺寸估算 **时间计算 (3个)** - `calculate_fade_out_start` - 淡出开始时间计算 - `calculate_end_time` - 结束时间计算 - `has_time_range` - 是否有时间范围 **滤镜构建 (4个)** - `build_scale_filter` - 缩放滤镜构建 - `build_opacity_filter` - 透明度滤镜构建 - `build_image_fade_filters` - 图片淡入淡出滤镜 - `build_enable_expr` - enable表达式构建 **drawtext相关 (4个)** - `escape_drawtext_text` - 特殊字符转义 - `build_drawtext_alpha_expr` - alpha淡入淡出表达式 - `build_stroke_params` - 描边参数 - `build_shadow_params` - 阴影参数 **贴纸管理 (3个)** - `sort_stickers_by_z_index` - z-index排序 - `filter_enabled_stickers` - 启用过滤 - `count_sticker_types` - 类型统计 **overlay相关 (2个)** - `build_overlay_position` - 位置参数构建 - `build_pre_filter_label` - 预处理标签构建 **验证函数 (2个)** - `validate_image_sticker` - 图片贴纸验证 - `validate_text_sticker` - 文字贴纸验证 ## 测试数据 - 新增测试: **141个** - 测试通过率: 100% - 全部为纯函数单元测试,无外部依赖

🚀 预览环境已部署

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

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

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

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

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

【阻塞级判定】

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

📊 审查概览

  • 整体评价:有建议
  • 建议级问题数量:3 个

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

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

  1. [.env.production.example] CosyVoice 配置变更风险

    • 具体内容:COSYVOICE_BASE_URL.../services/aigc/text2audio 变更为 .../api/v1,且模型版本从 v1 升级到 v3-flash。这是一个破坏性配置变更。请确保代码逻辑(不可见部分)已同步更新,能够正确处理新的 Base URL 拼接逻辑或请求路径,否则会导致语音合成服务在生产环境调用失败。
  2. [.gitea/workflows/ci-cd.yml] CI 管道删除验证

    • 具体内容:主 CI/CD 文件 ci-cd.yml 被删除,文件列表中新增了 ci-pipeline.yml 等文件。由于 Diff 被截断,无法审查新文件内容。强烈建议确认新的 CI 流程完全覆盖了原文件中的所有测试(单元测试、集成测试、E2E)、构建和部署步骤,避免 CI 覆盖缺失导致上线风险。
  3. [.gitea/workflows/acr-cleanup.yml] SSH 错误处理与安全性

    • 具体内容:在 "Get staging running images" 步骤中使用了 set +e,如果 SSH 连接失败(例如网络抖动或密钥失效),错误会被静默忽略,导致 PROTECTED_TAGS 为空。这可能导致后续清理脚本误删正在运行的服务镜像。建议增加对 SSH 命令退出码的检查,在获取白名单失败时发出警告或终止流程。

良好实践

  • Docker 登录安全:在 .gitea/workflows/acr-cleanup.yml 中使用 printf '%s' "$ACR_PASSWORD" 配合 --password-stdin 进行 Docker 登录,有效避免了密码中包含特殊字符或换行符导致的问题,是最佳实践。
  • 配置文档化.env.example 增加了非常详细的注释和配置读取规则说明,极大提高了项目的可维护性和新开发者的上手效率。
  • 并发控制acr-cleanup.yml 配置了 concurrency group,防止同一资源的清理任务并发冲突。

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

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:有建议 - 建议级问题数量:3 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 1. **[.env.production.example] CosyVoice 配置变更风险** - 具体内容:`COSYVOICE_BASE_URL` 从 `.../services/aigc/text2audio` 变更为 `.../api/v1`,且模型版本从 `v1` 升级到 `v3-flash`。这是一个破坏性配置变更。请确保代码逻辑(不可见部分)已同步更新,能够正确处理新的 Base URL 拼接逻辑或请求路径,否则会导致语音合成服务在生产环境调用失败。 2. **[.gitea/workflows/ci-cd.yml] CI 管道删除验证** - 具体内容:主 CI/CD 文件 `ci-cd.yml` 被删除,文件列表中新增了 `ci-pipeline.yml` 等文件。由于 Diff 被截断,无法审查新文件内容。**强烈建议**确认新的 CI 流程完全覆盖了原文件中的所有测试(单元测试、集成测试、E2E)、构建和部署步骤,避免 CI 覆盖缺失导致上线风险。 3. **[.gitea/workflows/acr-cleanup.yml] SSH 错误处理与安全性** - 具体内容:在 "Get staging running images" 步骤中使用了 `set +e`,如果 SSH 连接失败(例如网络抖动或密钥失效),错误会被静默忽略,导致 `PROTECTED_TAGS` 为空。这可能导致后续清理脚本误删正在运行的服务镜像。建议增加对 SSH 命令退出码的检查,在获取白名单失败时发出警告或终止流程。 ### ✅ 良好实践 - **Docker 登录安全**:在 `.gitea/workflows/acr-cleanup.yml` 中使用 `printf '%s' "$ACR_PASSWORD"` 配合 `--password-stdin` 进行 Docker 登录,有效避免了密码中包含特殊字符或换行符导致的问题,是最佳实践。 - **配置文档化**:`.env.example` 增加了非常详细的注释和配置读取规则说明,极大提高了项目的可维护性和新开发者的上手效率。 - **并发控制**:`acr-cleanup.yml` 配置了 `concurrency` group,防止同一资源的清理任务并发冲突。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-29 14:35:40 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia changed target branch from main to develop 2026-07-30 00:08:00 +08:00
xiaoxia added 3 commits 2026-07-30 00:08:00 +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个测试全部通过。
style: auto-format with black + isort + prettier [skip ci-format-check]
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 / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 48s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m26s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m33s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m37s
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
AI Code Review / AI Code Review (pull_request) Successful in 2m35s
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
PR Automation / Auto Approve on CI Green (pull_request) Successful in 4m10s
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m50s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 5m42s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 5m35s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m56s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 9m47s
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 36s
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
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m31s
9cb680ac01
xiaoxia merged commit d7e362a637 into develop 2026-07-30 00:25:31 +08:00

🗑️ 预览环境已清理

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

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

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