docs+test: 发布包对拍计划、pytest 双端 API 对拍与 run_elevator_parity 脚本

- docs/elevator-api-parity: 计划/报告模板/示例
- tools/elevator_api_parity: 端点目录、fixtures、对拍 client/compare、报告生成
- scripts/run_elevator_parity: JDK8 构建 + 单测/对拍(无服务时跳过对拍用例)

Made-with: Cursor

Former-commit-id: 3d54a40e1a7ae0b1724261d4f18910a6f415f853
This commit is contained in:
反编译工作区
2026-04-25 09:50:32 +08:00
parent 2cd9da61da
commit 038f846dad
24 changed files with 712 additions and 0 deletions
@@ -0,0 +1 @@
"""Parity report generator."""
@@ -0,0 +1,42 @@
from __future__ import annotations
from datetime import datetime
from pathlib import Path
from typing import List
def timestamped_name(prefix: str) -> str:
return f"{prefix}-{datetime.now().strftime('%Y%m%d-%H%M%S')}.md"
def write_file(
out_path: Path,
base_old: str,
base_new: str,
rows: List[dict],
) -> None:
lines = [
f"# 电梯应用 API 新旧对拍报告\n",
f"- **时间**: {datetime.now().isoformat()}\n",
f"- **基线(旧) URL**: {base_old}\n",
f"- **新构建 URL**: {base_new}\n",
"\n## 用例\n\n",
"| 用例 | 方法+路径 | HTTP(旧) | HTTP(新) | 等值 | 说明 |\n",
"| ---- | -------- | -------- | -------- | ---- | ---- |\n",
]
ok, bad = 0, 0
for r in rows:
name = r.get("name", "")
pth = f"{r.get('method', '')} {r.get('path', '')}"
s1, s2 = r.get("old_status", ""), r.get("new_status", "")
eq = "Y" if r.get("match") else "N"
if r.get("match"):
ok += 1
else:
bad += 1
msg = (r.get("message", "") or "").replace("|", "\\|")[:200]
lines.append(f"| {name} | `{pth}` | {s1} | {s2} | {eq} | {msg} |\n")
lines.append(
f"\n## 汇总\n- 通过: {ok},不一致: {bad}\n- **上线前请人工与联调/业务确认**。\n"
)
out_path.write_text("".join(lines), encoding="utf-8")