test(P3-1): 第51波 domain 单测 - quota/job/entities(+183) #840

Merged
xiaoxia merged 1 commits from test/wave51-domain-quota-job-entities into develop 2026-07-24 21:30:52 +08:00
Owner

变更内容

  • test_quota_domain.py: 72个测试
  • test_job_domain.py: 67个测试
  • test_entities_domain.py: 44个测试

覆盖模块

  • domain/quota.py(QuotaService + 配额计算逻辑)
  • domain/job.py(Job领域服务)
  • domain/entities.py(领域实体)

测试统计

新增 183 个单测,全部通过

## 变更内容 - test_quota_domain.py: 72个测试 - test_job_domain.py: 67个测试 - test_entities_domain.py: 44个测试 ## 覆盖模块 - domain/quota.py(QuotaService + 配额计算逻辑) - domain/job.py(Job领域服务) - domain/entities.py(领域实体) ## 测试统计 新增 183 个单测,全部通过
xiaoxia added 1 commit 2026-07-24 20:23:59 +08:00
test(p3-1): wave51 - quota/job/entities 领域层单测 +183
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 31s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 55s
CI/CD Pipeline / Validate - Type Check (mypy) (pull_request) Successful in 1m20s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m21s
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 - Code Quality (pull_request) Failing after 2m35s
Preview Deploy / Deploy Preview Environment (pull_request) Failing after 32s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 2m42s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m1s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m42s
AI Code Review / AI Code Review (pull_request) Successful in 4m8s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 7m21s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 13m9s
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) Failing after 3m25s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m54s
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 16s
b7aa4ac251
- quota: 配额维度/套餐/注册表/检查器/告警级别 全量测试 +72
- job: 任务类型/状态/创建/状态机/重试/序列化 全量测试 +67
- entities: User/Project/AssetLibrary/Asset/IngestJob/AssetStatus 全量测试 +44
- 合计 +183
Collaborator

代码审查结果 - PR #840

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

💡 建议(2个可选)

  1. tests/unit/test_entities_domain.py (多处):建议避免在单元测试中使用 time.sleep

    • 说明:在 test_add_tag_updates_updated_attest_remove_tag_updates_updated_at 等测试方法中使用了 time.sleep(0.001) 来等待时间更新。这会导致测试运行变慢,且在系统负载高时可能因时间精度问题导致测试不稳定(Flaky Tests)。
    • 建议:建议在领域层注入 Clockdatetime_provider,或者在测试中使用 unittest.mock.patch 来模拟时间递增,从而实现确定性的、快速的测试。
  2. tests/unit/test_entities_domain.py (多处):ID 长度校验较为脆弱

    • 说明:多处测试断言 assert len(project.id) == 32,这强耦合了当前的 ID 生成策略(假设是 32 位 hex 字符串)。如果未来 ID 生成策略改为 UUID(带横线)或 ULID,这些测试将全部失败。
    • 建议:如果 ID 格式不是业务强约束,建议仅校验 ID 非空或符合特定正则格式(如 hex 字符),而非固定长度。

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


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

## 代码审查结果 - PR #840 ### ⚠️ 问题(0个需要修改) 无 ### 💡 建议(2个可选) 1. **tests/unit/test_entities_domain.py (多处)**:建议避免在单元测试中使用 `time.sleep` - **说明**:在 `test_add_tag_updates_updated_at` 和 `test_remove_tag_updates_updated_at` 等测试方法中使用了 `time.sleep(0.001)` 来等待时间更新。这会导致测试运行变慢,且在系统负载高时可能因时间精度问题导致测试不稳定(Flaky Tests)。 - **建议**:建议在领域层注入 `Clock` 或 `datetime_provider`,或者在测试中使用 `unittest.mock.patch` 来模拟时间递增,从而实现确定性的、快速的测试。 2. **tests/unit/test_entities_domain.py (多处)**:ID 长度校验较为脆弱 - **说明**:多处测试断言 `assert len(project.id) == 32`,这强耦合了当前的 ID 生成策略(假设是 32 位 hex 字符串)。如果未来 ID 生成策略改为 UUID(带横线)或 ULID,这些测试将全部失败。 - **建议**:如果 ID 格式不是业务强约束,建议仅校验 ID 非空或符合特定正则格式(如 hex 字符),而非固定长度。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ⚠️ 建议关注性能 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-24 12:29:30 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit 972ff89990 into develop 2026-07-24 21:30:52 +08:00
xiaoxia deleted branch test/wave51-domain-quota-job-entities 2026-07-24 21:30:52 +08:00

🗑️ 预览环境已清理

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

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

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