test: P3-1 第48波单元测试(tag/verification_code/subtitle/voice_presets,+59) #836

Merged
xiaoxia merged 1 commits from test/wave48-domain-tag-verification-subtitle-voicepresets into develop 2026-07-24 18:58:14 +08:00
Owner

内容

新增4个领域模块的单元测试,合计 +59 个用例。

模块列表

  1. test_tag.py (4个) - Tag 标签领域实体

    • create 正常创建 / 空名称校验 / 空格名称校验 / ID唯一性
  2. test_verification_code.py (10个) - VerificationCode 验证码实体

    • create 默认TTL / 自定义TTL / 自定义验证码 / recipient strip
    • is_valid / is_expired / is_used 状态判断
    • mark_used / increment_attempts 操作
  3. test_subtitle.py (28个) - SubtitleTimeline 字幕时间轴模型

    • SubtitleWord / SubtitleSegment 基础属性
    • SubtitleTimeline 统计属性
    • merge_short_segments 短片段合并(含合并到末尾场景)
    • split_long_segments 长片段拆分(按标点断句)
    • _split_text_by_punctuation 标点断句工具
    • _merge_segments 合并工具
  4. test_voice_presets.py (17个) - 音色预设模块

    • VoiceGender / VoiceStyle 枚举值
    • VoicePreset 默认值 / 自定义值
    • MOCK_VOICES 数据完整性
    • get_voice / list_voices / get_default_voice 查询函数
    • 多条件筛选 / 关键词搜索 / 性别风格过滤
## 内容 新增4个领域模块的单元测试,合计 +59 个用例。 ### 模块列表 1. **test_tag.py** (4个) - Tag 标签领域实体 - create 正常创建 / 空名称校验 / 空格名称校验 / ID唯一性 2. **test_verification_code.py** (10个) - VerificationCode 验证码实体 - create 默认TTL / 自定义TTL / 自定义验证码 / recipient strip - is_valid / is_expired / is_used 状态判断 - mark_used / increment_attempts 操作 3. **test_subtitle.py** (28个) - SubtitleTimeline 字幕时间轴模型 - SubtitleWord / SubtitleSegment 基础属性 - SubtitleTimeline 统计属性 - merge_short_segments 短片段合并(含合并到末尾场景) - split_long_segments 长片段拆分(按标点断句) - _split_text_by_punctuation 标点断句工具 - _merge_segments 合并工具 4. **test_voice_presets.py** (17个) - 音色预设模块 - VoiceGender / VoiceStyle 枚举值 - VoicePreset 默认值 / 自定义值 - MOCK_VOICES 数据完整性 - get_voice / list_voices / get_default_voice 查询函数 - 多条件筛选 / 关键词搜索 / 性别风格过滤
xiaoxia added 1 commit 2026-07-24 18:07:15 +08:00
test: P3-1 第48波单元测试(tag/verification_code/subtitle/voice_presets,+59)
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 31s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m27s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m36s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m58s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 42s
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 / PR Build Web Image (pull_request) Successful in 42s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 39s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 18s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m24s
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 / PR Build API Image (pull_request) Successful in 6m9s
AI Code Review / AI Code Review (pull_request) Successful in 7m0s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 5m9s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 12m46s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m41s
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 / Production Browser E2E (pull_request) Has been skipped
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 5s
e1fd5243bb
新增4个领域模块单测:
- test_tag.py: Tag领域实体(4个)
- test_verification_code.py: VerificationCode验证码实体(10个)
- test_subtitle.py: 字幕时间轴模型(28个)- 合并/拆分/标点断句
- test_voice_presets.py: 音色预设查询(17个)

合计 +59 个测试用例,全部通过。
Collaborator

代码审查结果 - PR #836

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

💡 建议(1个可选)

  1. tests/unit/test_verification_code.py 第60行:避免在单元测试中使用 time.sleep。这会降低测试执行速度并引入不稳定性(依赖于系统时钟精度和调度)。建议使用 freezegun 等 Mock 时间库来控制时间,或者直接构造已过期的 VerificationCode 对象进行测试,而不依赖实际的时间流逝。

格式检查通过 | 逻辑审查通过 | ⚠️ 建议关注性能


🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 10:20:27 | 模型:

## 代码审查结果 - PR #836 ### ⚠️ 问题(0个需要修改) ### 💡 建议(1个可选) 1. **tests/unit/test_verification_code.py 第60行**:避免在单元测试中使用 `time.sleep`。这会降低测试执行速度并引入不稳定性(依赖于系统时钟精度和调度)。建议使用 `freezegun` 等 Mock 时间库来控制时间,或者直接构造已过期的 `VerificationCode` 对象进行测试,而不依赖实际的时间流逝。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ⚠️ 建议关注性能 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 10:20:27 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit 42335eff42 into develop 2026-07-24 18:58:14 +08:00
xiaoxia deleted branch test/wave48-domain-tag-verification-subtitle-voicepresets 2026-07-24 18:58:14 +08:00

🗑️ 预览环境已清理

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

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

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