test(P3-1): 第54波 domain 单测 - 剩余12个小模块(+62)domain层扫完 #844

Merged
xiaoxia merged 1 commits from test/wave54-domain-remaining-small-modules into develop 2026-07-24 21:31:00 +08:00
Owner

变更内容

  • test_domain_remaining_small_modules.py: 62个测试

覆盖模块(12个)

  • bgm_utils
  • exceptions
  • editing_mode
  • recipe
  • template
  • template_version
  • template_clip_config
  • preset_bgm
  • preset_voices
  • title_library
  • voice_library
  • classification_job

里程碑

domain层35个模块中33个全覆盖(2个兼容转发层asset/asset_library跳过)

测试统计

新增 62 个单测,全部通过

## 变更内容 - test_domain_remaining_small_modules.py: 62个测试 ## 覆盖模块(12个) - bgm_utils - exceptions - editing_mode - recipe - template - template_version - template_clip_config - preset_bgm - preset_voices - title_library - voice_library - classification_job ## 里程碑 domain层35个模块中33个全覆盖(2个兼容转发层asset/asset_library跳过) ## 测试统计 新增 62 个单测,全部通过
xiaoxia added 1 commit 2026-07-24 20:24:17 +08:00
test(p3-1): wave54 - domain层剩余小模块单测 +62
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 36s
CI/CD Pipeline / Validate - Code Quality (pull_request) Failing after 1m43s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m9s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 42s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m3s
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 1m54s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 58s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 22s
AI Code Review / AI Code Review (pull_request) Successful in 3m19s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m26s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 7m50s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 14m15s
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 / Integration Tests (pull_request) Successful in 4m7s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 4m21s
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 11s
817c5a46dc
覆盖以下 12 个模块:
- bgm_utils: merge_bgm_config 合并逻辑 +10
- editing_mode: EditingMode 枚举 +3
- exceptions: 4个异常类 +7
- recipe: Recipe/RecipeItem +4
- template: Template/TemplateSegment/TemplateCategory +4
- template_version: EditTemplateVersion +4
- template_clip_config: ClipType/TransitionEffect/TemplateClipConfig +6
- preset_bgm: PresetBGM/预设库/查询函数 +10
- preset_voices: PresetVoice/预置音色/查询函数 +10
- title_library: TitleLibraryItem +2
- voice_library: VoiceLibraryItem +2
- 合计 +62
Collaborator

代码审查结果 - PR #844

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

💡 建议(3个可选)

  1. tests/unit/test_domain_remaining_small_modules.py 第352行、424行:异常捕获范围过大

    • 问题描述:在测试 frozen 特性时使用了 pytest.raises(Exception)。虽然这能通过测试,但如果 __setattr__ 内部抛出了其他非预期的运行时错误(如 TypeError 或 AttributeError),测试也会错误地通过。
    • 修改建议:建议捕获具体的异常类型,例如 dataclasses.FrozenInstanceError(如果是 dataclass)或 AttributeError,以提高测试的精确性。
  2. tests/unit/test_domain_remaining_small_modules.py 第268行:ID 长度校验可能过于脆弱

    • 问题描述:test_create_basic 中断言 len(v.id) == 32。这硬编码了 ID 的生成策略(假设是 32 位字符串)。如果未来 ID 生成策略改变(如切换到 UUIDv4 的 36 位或 ULID),测试会失败。
    • 修改建议:建议只断言 v.id 是非空字符串,或者如果项目有统一的 ID 生成规范,可以保留,但需注意与实现强耦合。
  3. tests/unit/test_domain_remaining_small_modules.py 第387-409行:测试数据依赖可能导致脆弱性

    • 问题描述:test_search_preset_bgm_by_nametest_search_preset_bgm_by_tag 依赖于 PRESET_BGM_LIBRARY 中包含特定的中文关键词(如“阳光”、“轻快”)。如果预设库的数据内容发生变化,测试会失败。
    • 修改建议:建议在测试中构造 Mock 数据或 Fixture,或者确保 PRESET_BGM_LIBRARY 是被测试代码严格控制的不可变常量。

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


🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 12:45:57 | 模型:

## 代码审查结果 - PR #844 ### ⚠️ 问题(0个需要修改) ### 💡 建议(3个可选) 1. **tests/unit/test_domain_remaining_small_modules.py 第352行、424行**:异常捕获范围过大 - 问题描述:在测试 `frozen` 特性时使用了 `pytest.raises(Exception)`。虽然这能通过测试,但如果 `__setattr__` 内部抛出了其他非预期的运行时错误(如 TypeError 或 AttributeError),测试也会错误地通过。 - 修改建议:建议捕获具体的异常类型,例如 `dataclasses.FrozenInstanceError`(如果是 dataclass)或 `AttributeError`,以提高测试的精确性。 2. **tests/unit/test_domain_remaining_small_modules.py 第268行**:ID 长度校验可能过于脆弱 - 问题描述:`test_create_basic` 中断言 `len(v.id) == 32`。这硬编码了 ID 的生成策略(假设是 32 位字符串)。如果未来 ID 生成策略改变(如切换到 UUIDv4 的 36 位或 ULID),测试会失败。 - 修改建议:建议只断言 `v.id` 是非空字符串,或者如果项目有统一的 ID 生成规范,可以保留,但需注意与实现强耦合。 3. **tests/unit/test_domain_remaining_small_modules.py 第387-409行**:测试数据依赖可能导致脆弱性 - 问题描述:`test_search_preset_bgm_by_name` 和 `test_search_preset_bgm_by_tag` 依赖于 `PRESET_BGM_LIBRARY` 中包含特定的中文关键词(如“阳光”、“轻快”)。如果预设库的数据内容发生变化,测试会失败。 - 修改建议:建议在测试中构造 Mock 数据或 Fixture,或者确保 `PRESET_BGM_LIBRARY` 是被测试代码严格控制的不可变常量。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 12:45:57 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit f6a1798124 into develop 2026-07-24 21:31:00 +08:00
xiaoxia deleted branch test/wave54-domain-remaining-small-modules 2026-07-24 21:31:00 +08:00

🗑️ 预览环境已清理

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

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

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