test(wave103): 抽取clip_operations纯逻辑模块 + 57个单测 #977

Closed
xiaoxia wants to merge 1 commits from test/wave103-clip-operations into develop
Owner

变更内容

edit_plan_service.py 抽离片段操作纯逻辑到 packages/domain/clip_operations.py,便于独立测试和复用。

拆分内容

  • SplitResult / MergeResult:结果数据类(frozen)
  • validate_split_time:分割时间合法性校验
  • calculate_split:分割参数计算(左右时长 / right_start_time / trim 信息)
  • validate_merge_clips:合并校验(同计划 / order 连续 / 同类型)
  • calculate_merge:合并参数计算(总时长 / 文案合并 / config 合并 / trim 清理)
  • calculate_reorder_new_orders:重排 order 计算
  • calculate_shift_orders:order 偏移计算

接入服务

edit_plan_service.pysplit_clipmerge_clips 方法已接入新模块:

  • 校验逻辑委托给 validate_* 函数
  • 计算逻辑委托给 calculate_* 函数
  • DB 操作保留在 service 层
  • 原有 55 个 edit_plan_service 测试全部通过

代码规模

  • edit_plan_service.py: 648 行 → 639 行(-9 行,逻辑更清晰)
  • 新模块: 267 行

测试

+57 个单测,覆盖:

  • validate_split_time: 8 个用例(合法 / 零 / 负 / 等于duration / 超 / 极小 / 接近末尾 / 错误消息)
  • calculate_split: 11 个用例(中间 / 开头 / 结尾 / start_time / 零start_time / 精度 / 默认精度 / 自定义精度 / 非法抛异常 / trim匹配 / frozen)
  • validate_merge_clips: 9 个用例(2个 / 3个 / 乱序 / 单片段 / 空 / 不同计划 / 不连续 / 不同类型 / 中间缺)
  • calculate_merge: 12 个用例(2个时长 / 3个时长 / 乱序 / 文案合并 / 跳空文案 / 全空 / config覆盖 / config None / trim移除 / 空 / 单片段 / frozen)
  • calculate_reorder_new_orders: 7 个用例(交换 / 3元素 / 不变 / 不匹配 / 多出ID / 缺少ID / 自定义属性)
  • calculate_shift_orders: 7 个用例(正偏移 / 负偏移 / 排除ID / 无元素 / 零偏移 / 严格大于 / 空列表)
  • 端到端集成:分割+前移 / 合并+后移

验证结果:112 passed(55 原有 edit_plan_service + 57 新增),全绿。

关联

单测主线第103波,边测边拆大文件(edit_plan_service.py)。

## 变更内容 从 `edit_plan_service.py` 抽离片段操作纯逻辑到 `packages/domain/clip_operations.py`,便于独立测试和复用。 ### 拆分内容 - **SplitResult / MergeResult**:结果数据类(frozen) - **validate_split_time**:分割时间合法性校验 - **calculate_split**:分割参数计算(左右时长 / right_start_time / trim 信息) - **validate_merge_clips**:合并校验(同计划 / order 连续 / 同类型) - **calculate_merge**:合并参数计算(总时长 / 文案合并 / config 合并 / trim 清理) - **calculate_reorder_new_orders**:重排 order 计算 - **calculate_shift_orders**:order 偏移计算 ### 接入服务 `edit_plan_service.py` 的 `split_clip` 和 `merge_clips` 方法已接入新模块: - 校验逻辑委托给 validate_* 函数 - 计算逻辑委托给 calculate_* 函数 - DB 操作保留在 service 层 - 原有 55 个 edit_plan_service 测试全部通过 ### 代码规模 - edit_plan_service.py: 648 行 → 639 行(-9 行,逻辑更清晰) - 新模块: 267 行 ## 测试 **+57 个单测**,覆盖: - validate_split_time: 8 个用例(合法 / 零 / 负 / 等于duration / 超 / 极小 / 接近末尾 / 错误消息) - calculate_split: 11 个用例(中间 / 开头 / 结尾 / start_time / 零start_time / 精度 / 默认精度 / 自定义精度 / 非法抛异常 / trim匹配 / frozen) - validate_merge_clips: 9 个用例(2个 / 3个 / 乱序 / 单片段 / 空 / 不同计划 / 不连续 / 不同类型 / 中间缺) - calculate_merge: 12 个用例(2个时长 / 3个时长 / 乱序 / 文案合并 / 跳空文案 / 全空 / config覆盖 / config None / trim移除 / 空 / 单片段 / frozen) - calculate_reorder_new_orders: 7 个用例(交换 / 3元素 / 不变 / 不匹配 / 多出ID / 缺少ID / 自定义属性) - calculate_shift_orders: 7 个用例(正偏移 / 负偏移 / 排除ID / 无元素 / 零偏移 / 严格大于 / 空列表) - 端到端集成:分割+前移 / 合并+后移 **验证结果**:112 passed(55 原有 edit_plan_service + 57 新增),全绿。 ## 关联 单测主线第103波,边测边拆大文件(edit_plan_service.py)。
xiaoxia added 1 commit 2026-07-26 18:44:11 +08:00
test(wave103): 抽取clip_operations纯逻辑模块 + 57个单测
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 24s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1m0s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m12s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m11s
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 16s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 16s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m54s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 50s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 50s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m52s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m41s
AI Code Review / AI Code Review (pull_request) Successful in 6m30s
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 / Unit Tests (pull_request) Successful in 3m36s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m12s
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 / Canary Release to Production (pull_request) Has been cancelled
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 14s
18ef9529eb
从 edit_plan_service.py 抽离片段操作纯逻辑到 packages/domain/clip_operations.py:
- SplitResult / MergeResult 数据类
- validate_split_time: 分割时间校验
- calculate_split: 分割参数计算(左右时长/start_time/trim信息)
- validate_merge_clips: 合并校验(同计划/连续/同类型)
- calculate_merge: 合并参数计算(总时长/文案/config合并/trim清理)
- calculate_reorder_new_orders: 重排order计算
- calculate_shift_orders: order偏移计算

edit_plan_service.py 的 split_clip / merge_clips 已接入新模块
原有 55 个 edit_plan_service 测试全部通过

测试:+57 个单测
- validate_split_time: 合法/零/负/等于duration/超/极小/接近末尾/错误消息
- calculate_split: 中间/开头/结尾/带start_time/零start_time/精度/默认精度/
  自定义精度/非法抛异常/trim匹配/frozen
- validate_merge_clips: 2个/3个/乱序/单片段/空列表/不同计划/不连续/
  不同类型/中间缺
- calculate_merge: 2个时长/3个时长/乱序/文案合并/跳空文案/全空/
  config覆盖/config None/trim移除/空列表/单片段/精度/frozen
- calculate_reorder_new_orders: 交换/3元素/不变/不匹配/多出ID/缺少ID/自定义属性
- calculate_shift_orders: 正偏移/负偏移/排除ID/无元素/零偏移/严格大于/空列表
- 端到端:分割+前移 / 合并+后移

edit_plan_service.py: 648→639行(-9行,拆分后更清晰)
新模块: 267行
xiaoxia force-pushed test/wave103-clip-operations from 11224fcece to 18ef9529eb 2026-07-26 18:44:11 +08:00 Compare

🚀 预览环境已部署

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

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

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

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

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

🗑️ 预览环境已清理

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

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

🗑️ **预览环境已清理** PR #977 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Some checks are pending
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 24s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 1m0s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m12s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m11s
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 16s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 16s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m54s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 50s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 50s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 3m52s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m41s
AI Code Review / AI Code Review (pull_request) Successful in 6m30s
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 / Unit Tests (pull_request) Successful in 3m36s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m12s
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 / Canary Release to Production (pull_request) Has been cancelled
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 14s

Pull request closed

Sign in to join this conversation.