Files
vscode-workbench/PLANNING/PROGRESS_S-01.md
T

51 lines
3.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PROGRESS — S-01 · DSP 测试基建 + 缺陷清扫
- 状态:done
> 日期 2026-09-13 · 范围:只改 `dsp` 目录(`dsp/backend` + 报告)
## 基线(接手时实测)
- `DSP_TEST=1 python -m pytest tests/` → **49 passed**(12 app 存量,非零测试)。
- 不带 `DSP_TEST=1` 跑 → 37 errors(连 PG 超时):conftest 置变量晚于 pytest-django 初始化,
必须命令行前置 `DSP_TEST=1`(已写入统一入口,不改 conftest 行为)。
- 真缺口:无统一入口、无 report.json、无 `--http` 交叉验证;5 处外部 id 裸 `int()`;
visitors/logs/搜索边界覆盖薄。
## 改动(全部在 `C:/Users/12914/Desktop/dsp/` 内)
1. `dsp/backend/tests/e2e/run_e2e.py`(新建):统一入口——pytest 包装(ASGI 默认)+
`--http/--base-url` 真实服务交叉(health/search-hot/feed 三探针,失联优雅报告 connect FAIL)+
`report.json`(total/passed/failed/errored/skipped/duration/groups/http)。
2. `dsp/backend/tests/e2e/test_gap_coverage.py`(新建,12 条):访客记录/列表、自访 400、
访客匿名 401、搜索空/脏查询不 500、suggest+hot、logs 上报闭环、通知列表+已读、
审核举报流、评论 missing-video 4xx、裸 int 静态自查、软删过滤静态自查。
3. 缺陷清扫(静态自查真抓到 5 处,已修):
- `core/api.py`:新增 `opt_id()`(非正整数回落,不抛 500)。
- `apps/visitors|moderation|creator|messages_app`:裸 `int(...get(...))` → `opt_id`;
`apps/music`:手写 clamp → `parse_page_size`。
4. `dsp/backend/tests/e2e/__init__.py`(新建空包)。
## 验收对照
- [x] 统一入口 `61 passed`(49 存量 + 12 新增)≥60
- [x] 存量零删除零跳过(skipped=0)
- [x] `report.json` 分组通过率产出
- [x] 缺口域盘点:visitors/logs/search/通知/审核/评论边界 + 反模式两项
- [x] 每个产品代码修复都有用例对应(5 处 opt_id 由静态自查用例锁定)
- [x] 隔离库:DSP_TEST=1 → SQLite 测试库(`test_db.sqlite3`),原始开发库零改动
- [x] 5xx:`?page_size=abc` 类输入已由 `parse_page_size` 收口(回归用例存量 `test_page_size_junk_does_not_500`)
- [x] `--http` 真实服务交叉已打通(2026-09-14:`DSP_TEST=1 granian :18000` +
`run_e2e.py --http --base-url http://127.0.0.1:18000` → health/search-hot/feed 3/3 PASS;
61 用例全绿,report.json `mode=http`)
## 验证
```bash
cd dsp/backend && DSP_TEST=1 python tests/e2e/run_e2e.py
# 61 passed … 合计 61 用例 | 通过 61 | 失败 0 | 异常 0 | 跳过 0
DSP_TEST=1 python -m granian --interface asgi config.asgi:application --host 127.0.0.1 --port 18000 &
DSP_TEST=1 python tests/e2e/run_e2e.py --http --base-url http://127.0.0.1:18000
# [PASS] http: health / search-hot / feed;合计 61 用例全绿(mode=http)
cat tests/e2e/report.json
```
## 状态
done(ASGI + `--http` 双模式全绿)。各项目目录改动由各仓自行归属,本仓仅收 PROGRESS 证据。