test(nightly): cover crud.photo batch_create/save_and_create/replace (2026-08-21) - #142
test(nightly): cover crud.photo batch_create/save_and_create/replace (2026-08-21)#142LC044 wants to merge 4 commits into
Conversation
…(2026-08-21) - 新增覆盖: app.crud.photo (batch_create_photos 去重 + save_and_create_photo FileType dispatch + replace_photo_file 文件替换), 6 用例. - 模式: MagicMock + patch.object, 零 DB / 网络依赖 (与 nightly 2026-08-17 一致, 规避 SQLite pollution). Nightly watch run 2026-08-21 Co-authored-by: Codex <noreply@openai.com>
|
Nightly watch follow-up #9b (2026-08-21 11:00 CST): 完整 E2E 300 passed / 4 skipped / 0 failed in 7m (run.log 落盘到 tests/artifacts/nightly/2026-08-21/run.log)。 |
…-08-21)
- Adds 34 unit cases in package/server/tests/unit/test_nightly_api_settings_directories_gaps_20260821.py
exercising the previously untested endpoints on app/api/settings.py:
GET /models, POST /verify-connection, DELETE /ai-models/{model_id},
POST /directories, DELETE /directories, GET /directories/browse,
GET /directories/candidates, POST /directories/validate,
POST /directories/batch, PUT /storage-root, POST /filter/apply,
POST /map/upload, GET /map/files/{filename}.
- Rationale (2nd round on api/settings.py gap-list, follows crud/photo coverage
on commit 58d6149): the Cobertura trace from the previous watch listed
api/settings.py at 48.2% (282 missed). This new file targets the high-density
miss lines with MagicMock + AsyncMock isolation (no DB, no HTTP).
Nightly watch run 2026-08-21
Co-authored-by: Codex <noreply@openai.com>
Nightly watch round 2 (2026-08-21)
Decisions
Follow-up gaps (queue for next round)
Round 1 commit 🤖 generated by Codex nightly agent |
Deploying trailsnap with
|
| Latest commit: |
6bf7dba
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://635184a4.trailsnap-bfa.pages.dev |
| Branch Preview URL: | https://nightly-test-watch-20260821.trailsnap-bfa.pages.dev |
What
新增 6 个单元测试覆盖
app/crud/photo.py中覆盖率长期偏低的三个函数:batch_create_photos-- file_path dedup (DB 已存在 + 批内重复) + bulk insertsave_and_create_photo-- file-extension -> FileType dispatch (.mp4走 video 分支, 默认 image)replace_photo_file-- 删除旧文件 + 缩略图重新生成 + 路径变更/不变两种分支Why
2026-08-19 nightly coverage scan 显示
app/crud/photo.py上述函数仍未被覆盖. 沿用 2026-08-17 / 2026-08-19 nightly round 的 MagicMock +patch.object模式, 规避 SQLite pollution (memory 2026-08-19 持续问题).How
pytestmark = [pytest.mark.smoke]-- 与既有 nightly 测试一致crud/photo.py中函数体内 lazy import (from app.crud.album,from app.service.task_manager) -> 在源模块上 patch (patch.multiple('app.crud.album', ...),patch('app.service.task_manager.TaskManager', fake))replace_photo_filecommit 后触发TaskManager.get_instance().add_tasks走下游副作用, 用_patch_task_manager()stubtmp_pathfixture, 不依赖data/uploads/uv run pytest tests/unit/test_nightly_crud_photo_gaps_20260821.py-> 6 passed)Test
`
uv run python -m pytest tests/unit/test_nightly_crud_photo_gaps_20260821.py -v
6 passed, 14 warnings in 2.80s
`
Notes
tests/范围改动 (符合 §0 影响范围), 不动生产代码Nightly watch run 2026-08-21
Co-authored-by: Codex noreply@openai.com