test(unit): P3-1第七波 entities领域模块单元测试(80个用例) #709

Merged
xiaoxia merged 5 commits from test/p3-1-wave7-entities-domain-tests into develop 2026-07-22 16:36:50 +08:00
Owner

新增测试(80个用例)

覆盖 entities.py 全部9个类型:

枚举(4个)

  • AssetLibraryKind - VIDEO/VOICE/IMAGE
  • IngestJobStatus - PENDING/PROCESSING/COMPLETED/FAILED
  • AssetStatus - 标准值 + missing 兼容逻辑(uploaded/success/done/fail/process/未知值兜底)
  • ClassificationStatus - 标准值 + missing 兼容逻辑(done/success/fail/process/未知值兜底)

数据类(5个)

  • User - 认证/订阅/配额/微信/手机绑定全字段
  • Project - create/is_owner/is_shared_with/can_access
  • AssetLibrary - create/kind校验/命名规范化
  • Asset - create参数校验/file_type/add_tag去重/remove_tag幂等/时间戳更新
  • IngestJob - create校验/状态流转/结果关联

验证

  • 全量 3321 个单测通过,8 skipped
## 新增测试(80个用例) 覆盖 entities.py 全部9个类型: ### 枚举(4个) - **AssetLibraryKind** - VIDEO/VOICE/IMAGE - **IngestJobStatus** - PENDING/PROCESSING/COMPLETED/FAILED - **AssetStatus** - 标准值 + _missing_ 兼容逻辑(uploaded/success/done/fail/process/未知值兜底) - **ClassificationStatus** - 标准值 + _missing_ 兼容逻辑(done/success/fail/process/未知值兜底) ### 数据类(5个) - **User** - 认证/订阅/配额/微信/手机绑定全字段 - **Project** - create/is_owner/is_shared_with/can_access - **AssetLibrary** - create/kind校验/命名规范化 - **Asset** - create参数校验/file_type/add_tag去重/remove_tag幂等/时间戳更新 - **IngestJob** - create校验/状态流转/结果关联 ## 验证 - 全量 3321 个单测通过,8 skipped
xiaoxia added 3 commits 2026-07-22 14:01:20 +08:00
- test_tag_domain: Tag领域模型测试
- test_recipe_domain: Recipe领域模型测试
- test_editing_mode_domain: EditingMode枚举测试
- test_title_library_domain: TitleLibraryItem领域模型测试
- test_voice_library_domain: VoiceLibraryItem领域模型测试
test(unit): 补充MemoryStateStore单元测试(10个用例)
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 / Deploy Staging (Watchtower auto-deploy) (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 / 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 / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 38s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 4s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 19s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m30s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1m19s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m5s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 3m2s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m3s
AI Code Review / AI Code Review (pull_request) Successful in 4m7s
7172039353
覆盖 #558 微信登录 CSRF 防护核心逻辑:
- 正常存取与一次性消费
- 过期清理(TTL机制)
- 多 state 互不干扰
- 并发写入与消费安全
- 空 state 边界情况
test(unit): P3-1第七波 entities领域模块单元测试(80个用例)
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 / Check if frontend-only change (pull_request) Successful in 14s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m52s
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
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 34s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
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
CI/CD Pipeline / Unit Tests (pull_request) Successful in 29s
AI Code Review / AI Code Review (pull_request) Successful in 4m10s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 1m27s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 2m32s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m6s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 22m1s
da7a9638b9
覆盖 entities.py 全部9个类型:
- 4个枚举: AssetLibraryKind, IngestJobStatus, AssetStatus, ClassificationStatus
  - 含 _missing_ 兼容逻辑全面覆盖(uploaded/success/done/fail/process等历史值)
- 5个数据类: User, Project, AssetLibrary, Asset, IngestJob
  - User: 认证/订阅/配额/微信/手机绑定全字段
  - Project: create/is_owner/is_shared_with/can_access
  - AssetLibrary: create/kind校验
  - Asset: create参数校验/file_type/add_tag/remove_tag去重与幂等
  - IngestJob: create校验/状态流转

🚀 预览环境已部署

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

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

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

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

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

代码审查结果 - PR #709

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

💡 建议(1个可选)

  1. tests/unit/test_entities_domain.py 第446行 & 第476行:建议避免使用 time.sleep 进行时间相关测试
    • 说明:在 test_add_tag_updates_updated_attest_remove_tag_updates_updated_at 中使用了 sleep(0.001) 来等待时间流逝。虽然延迟很短,但这会增加测试运行时间,且在系统负载高时可能导致测试不稳定(Flaky Test)。
    • 建议:推荐使用 freezegun 等 Mock 时间库,或者在领域对象设计中支持注入时间提供者,以便在测试中精确控制 updated_at 的值,从而避免依赖系统时钟。

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


🤖 由 AI 代码审查机器人自动生成 | 2026-07-22 14:06:42 | 模型:

## 代码审查结果 - PR #709 ### ⚠️ 问题(0个需要修改) 无 ### 💡 建议(1个可选) 1. **tests/unit/test_entities_domain.py 第446行 & 第476行**:建议避免使用 `time.sleep` 进行时间相关测试 - **说明**:在 `test_add_tag_updates_updated_at` 和 `test_remove_tag_updates_updated_at` 中使用了 `sleep(0.001)` 来等待时间流逝。虽然延迟很短,但这会增加测试运行时间,且在系统负载高时可能导致测试不稳定(Flaky Test)。 - **建议**:推荐使用 `freezegun` 等 Mock 时间库,或者在领域对象设计中支持注入时间提供者,以便在测试中精确控制 `updated_at` 的值,从而避免依赖系统时钟。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无明显问题 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-22 14:06:42 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
gitea-actions bot added 1 commit 2026-07-22 14:07:17 +08:00
xiaoxia added 1 commit 2026-07-22 16:27:59 +08:00
chore: trigger CI
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 0s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (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 / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (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
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 53s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 53s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 2m38s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 2m53s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 5m6s
AI Code Review / AI Code Review (pull_request) Failing after 5m56s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m5s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 26s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 8m52s
b1f1f06041
auto-approve-bot approved these changes 2026-07-22 16:33:07 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
auto-approve-bot approved these changes 2026-07-22 16:33:07 +08:00
auto-approve-bot left a comment
Collaborator

CI全绿,自动审批通过。

CI全绿,自动审批通过。
xiaoxia merged commit 4e042ba597 into develop 2026-07-22 16:36:50 +08:00

🗑️ 预览环境已清理

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

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

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