test(wave206): InMemory仓储单测补全 +72测 #1173

Merged
xiaoxia merged 3 commits from test/wave206-inmemory-repos into develop 2026-07-30 00:26:12 +08:00
Owner

变更内容

InMemoryAssetRepository(46测)

  • CRUD基础操作: create/get/update/delete/find_by_id
  • 查询过滤: list_by_project/list_by_library/find_by_library_and_file_type
  • 批量操作: batch_delete(软删除)/batch_update_metadata/batch_add_tags(去重)/batch_replace_tags
  • 分页查询: find_by_project(skip+limit)/find_by_tag_ids(分页)
  • 去重检测: find_by_library_and_file_hash

InMemoryUserRepository(26测)

  • 保存与ID查找
  • 各索引查找: email(大小写不敏感)/username/verification_token/reset_token/wechat_openid/wechat_unionid/phone
  • 删除用户及索引清理

修复

  • user_repository.save更新用户时先清理旧索引,避免索引残留

测试统计

  • 新增测试: 72个
  • 本地验证: pytest全绿 + black + ruff通过
## 变更内容 ### InMemoryAssetRepository(46测) - CRUD基础操作: create/get/update/delete/find_by_id - 查询过滤: list_by_project/list_by_library/find_by_library_and_file_type - 批量操作: batch_delete(软删除)/batch_update_metadata/batch_add_tags(去重)/batch_replace_tags - 分页查询: find_by_project(skip+limit)/find_by_tag_ids(分页) - 去重检测: find_by_library_and_file_hash ### InMemoryUserRepository(26测) - 保存与ID查找 - 各索引查找: email(大小写不敏感)/username/verification_token/reset_token/wechat_openid/wechat_unionid/phone - 删除用户及索引清理 ### 修复 - user_repository.save更新用户时先清理旧索引,避免索引残留 ## 测试统计 - 新增测试: 72个 - 本地验证: pytest全绿 + black + ruff通过
xiaoxia added 2 commits 2026-07-29 23:00:14 +08:00
test(wave205): path_security 单测重构与补全 +46测
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 5s
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 / Validate - Type Check (mypy) (pull_request) Successful in 1m14s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m16s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
92d5b3f26c
- 从 unittest 迁移到 pytest 风格
- 修正导入路径为标准包导入
- 覆盖 sanitize_filename / is_path_safe / is_in_allowed_dirs / safe_resolve_path
- 覆盖边界: 路径遍历、空路径、超长路径、特殊字符、符号链接等
test(wave206): InMemory仓储单测补全 +72测
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 29s
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 / Validate - Type Check (mypy) (pull_request) Successful in 1m16s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m20s
CI/CD Pipeline / Validate - Code Quality (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Lint (pull_request) Has been cancelled
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Web Image (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
Preview Deploy / Deploy Preview Environment (pull_request) Has been cancelled
c2ec722644
- InMemoryAssetRepository: 46测,覆盖CRUD/批量操作/分页/标签/哈希去重
- InMemoryUserRepository: 26测,覆盖各索引查找/删除/保存
- 修复user_repository.save更新时旧索引未清理问题

🚀 预览环境已部署

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

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

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

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

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1173 | | 预览链接 | [https://pr-1173.preview.xiaoxiajianji.com](https://pr-1173.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot added 1 commit 2026-07-29 23:07:55 +08:00
style: auto-format with black + isort + prettier [skip ci-format-check]
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 25s
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 / Validate - Type Check (mypy) (pull_request) Successful in 1m18s
CI/CD Pipeline / Validate - Migration (alembic) (pull_request) Successful in 1m30s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 39s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m9s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
AI Code Review / AI Code Review (pull_request) Successful in 3m44s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m18s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Validate - Code Quality (pull_request) Successful in 4m46s
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 / PR Build API Image (pull_request) Successful in 2m51s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m42s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 4m54s
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 Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m58s
CI/CD Pipeline / CI Gate (pull_request) Successful in 9s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Has been cancelled
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 57s
426639d22f
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:否
  • 阻塞级问题数量:0 个

📊 审查概览

  • 整体评价:通过
  • 建议级问题数量:0 个

🔴 阻塞级问题(必须修复)

💡 改进建议(不阻塞合并)

良好实践

  1. user_repository.py: save 方法中增加了完善的索引清理逻辑。在更新用户数据前,先移除旧的索引记录(email, username, token 等),有效解决了 InMemoryRepository 在更新对象时可能导致的索引不一致或脏数据问题。逻辑严密,覆盖了所有可选字段的清理。
  2. test_inmemory_user_repository.py: 新增的 TestIndexUpdates 测试类非常及时,专门针对索引更新的边界情况(如相同邮箱不同大小写、索引覆盖等)进行了验证,确保了修复的健壮性。
  3. 测试覆盖: 新增的 test_inmemory_asset_repository.py 测试文件覆盖面广,包含了分页、批量操作、软删除等复杂场景,测试用例编写规范,断言清晰。

格式检查通过 | 逻辑审查通过 | 性能良好


🤖 由 AI 代码审查机器人自动生成 | 2026-07-29 15:14:25 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:否 - 阻塞级问题数量:0 个 ### 📊 审查概览 - 整体评价:通过 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 无 ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 1. **`user_repository.py`**: `save` 方法中增加了完善的索引清理逻辑。在更新用户数据前,先移除旧的索引记录(email, username, token 等),有效解决了 InMemoryRepository 在更新对象时可能导致的索引不一致或脏数据问题。逻辑严密,覆盖了所有可选字段的清理。 2. **`test_inmemory_user_repository.py`**: 新增的 `TestIndexUpdates` 测试类非常及时,专门针对索引更新的边界情况(如相同邮箱不同大小写、索引覆盖等)进行了验证,确保了修复的健壮性。 3. **测试覆盖**: 新增的 `test_inmemory_asset_repository.py` 测试文件覆盖面广,包含了分页、批量操作、软删除等复杂场景,测试用例编写规范,断言清晰。 --- ✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能良好 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-07-29 15:14:25 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit 89639a6d3e into develop 2026-07-30 00:26:12 +08:00

🗑️ 预览环境已清理

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

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

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