feat(export): 采纳定额携带含量算式与换算调整,屏蔽金额汇总行改价同步
This commit is contained in:
38
test/core_intent_coverage/README.md
Normal file
38
test/core_intent_coverage/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# core_intent_coverage —— 核心设计意图覆盖核验工具包
|
||||
|
||||
## 它是什么
|
||||
一个**只读、零污染**的静态核验工具:把你最怕"改坏"的那几条业务口径(设计意图)
|
||||
列成 `intents.json`,扫描 `CostReview/app` 源码与 `app/tests` 测试,报告这些意图
|
||||
**有没有被现有 p0/p1 测试真正断言到**。
|
||||
|
||||
直接服务于「上市前第一步:功能验收 + 回归」——
|
||||
先确认既有测试是不是真把你的设计设想编码成了断言,而不是只在跑 happy-path 冒烟。
|
||||
|
||||
## 安全边界(硬规矩)
|
||||
- **绝不 import 任何 app 模块** → 不会触发 app 副作用、不会写库。
|
||||
- **绝不向 `CostReview/` 写任何文件** → 输出只落在本包 `out/`。
|
||||
- 对工程目录只做 `open(..., 'r')`。
|
||||
|
||||
## 怎么跑
|
||||
```bash
|
||||
cd D:/PricingReview/test/core_intent_coverage
|
||||
python run.py
|
||||
# 或自定义路径:
|
||||
python run.py --app D:/PricingReview/CostReview/app --tests D:/PricingReview/CostReview/app/tests
|
||||
```
|
||||
零依赖(仅 Python 标准库,3.9+)。
|
||||
|
||||
## 输出
|
||||
- `out/report.md` —— 人读报告(每条意图:源码是否存在 / 是否被测试覆盖 / 强度 / 断言数 / 命中测试)。
|
||||
- `out/report.json` —— 机读,便于后续接入台账或 CI。
|
||||
|
||||
## 已知局限(诚实声明)
|
||||
1. 这是**静态启发式**扫描(子串匹配 + 按 `test_` 函数分块统计 assert 数),
|
||||
不等于运行态验证。它告诉你"哪里可能有断言",但**不保证断言逻辑正确**。
|
||||
2. 标记词(markers)是关键词近似,可能误报/漏报;请结合 `report.md` 人工核对。
|
||||
3. "在结果上修改"指的是**完善本工具的 `intents.json` / 调标记词**(改的是工具自己的配置,
|
||||
不是你的软件代码)。若要在 `CostReview` 里**新增测试补缺口**,按你的规矩须由你/我显式确认后再动。
|
||||
|
||||
## 与 `CostReview/app/tests` 的关系
|
||||
`app/tests` 是**真正的测试用例**(会跑、会动 DB,靠 `api_harness` 隔离副本)。
|
||||
本工具是**元层检查器**:只读它们,不重复它们,不改它们。
|
||||
6
test/core_intent_coverage/__init__.py
Normal file
6
test/core_intent_coverage/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""core_intent_coverage —— 核心设计意图覆盖核验工具包。
|
||||
|
||||
只读、零污染:只扫描 CostReview 的源码与测试文本,绝不 import 工程模块,
|
||||
绝不向工程目录写文件。输出仅落在本包 out/ 目录。
|
||||
"""
|
||||
208
test/core_intent_coverage/checker.py
Normal file
208
test/core_intent_coverage/checker.py
Normal file
@@ -0,0 +1,208 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""核心设计意图覆盖核验(只读、零污染)。
|
||||
|
||||
用途:
|
||||
主人最怕"改坏"的那几条业务口径(设计意图)有没有被现有 p0/p1 测试真正断言到。
|
||||
做法:
|
||||
纯文本静态扫描——只读取 CostReview 的源码与测试,绝不 import、绝不写回。
|
||||
输出:
|
||||
out/report.md(人读)+ out/report.json(机读),落在工具包自己的 out/ 目录。
|
||||
|
||||
安全边界(硬规矩,违反即删):
|
||||
- 不 import 任何 app 模块(避免触发 app 副作用 / 写库)。
|
||||
- 不向 CostReview/ 写任何文件(输出只落本工具包 out/)。
|
||||
- 只 open(..., 'r'),对工程目录绝不 open(..., 'w')。
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
BASE = Path(__file__).resolve().parent
|
||||
DEFAULT_INTENTS = str(BASE / "intents.json")
|
||||
APP_DEFAULT = r"D:/PricingReview/CostReview/app"
|
||||
TESTS_DEFAULT = r"D:/PricingReview/CostReview/app/tests"
|
||||
OUT_DEFAULT = str(BASE / "out")
|
||||
|
||||
|
||||
def _iter_py(root):
|
||||
root = Path(root)
|
||||
if root.is_file() and root.suffix == ".py":
|
||||
yield root
|
||||
return
|
||||
if not root.is_dir():
|
||||
return
|
||||
for p in root.rglob("*.py"):
|
||||
if "__pycache__" in p.parts:
|
||||
continue
|
||||
yield p
|
||||
|
||||
|
||||
def scan_source(app_dir, markers):
|
||||
"""返回 {marker: [(rel, lineno, snippet)]} 与 matched_files 集合。"""
|
||||
hits = {m: [] for m in markers}
|
||||
matched_files = set()
|
||||
app_dir = Path(app_dir)
|
||||
for p in _iter_py(app_dir):
|
||||
try:
|
||||
text = p.read_text(encoding="utf-8", errors="replace")
|
||||
except Exception:
|
||||
continue
|
||||
rel = str(p.relative_to(app_dir)) if p.is_relative_to(app_dir) else str(p)
|
||||
for i, line in enumerate(text.splitlines(), 1):
|
||||
for m in markers:
|
||||
if m in line:
|
||||
hits[m].append((rel, i, line.strip()[:120]))
|
||||
matched_files.add(rel)
|
||||
return hits, matched_files
|
||||
|
||||
|
||||
def scan_tests(tests_dir, markers):
|
||||
"""对每个 marker,返回命中的 (file, func, assert_count) 列表(按 test 函数分块)。"""
|
||||
results = {m: [] for m in markers}
|
||||
tests_dir = Path(tests_dir)
|
||||
for p in _iter_py(tests_dir):
|
||||
try:
|
||||
text = p.read_text(encoding="utf-8", errors="replace")
|
||||
except Exception:
|
||||
continue
|
||||
rel = str(p.relative_to(tests_dir)) if p.is_relative_to(tests_dir) else str(p)
|
||||
lines = text.splitlines()
|
||||
cur_func, cur_start = None, 0
|
||||
for i, line in enumerate(lines, 1):
|
||||
m = re.match(r"\s*def\s+(test_\w+)\s*\(", line)
|
||||
if m:
|
||||
if cur_func is not None:
|
||||
_classify(results, markers, rel, cur_func, lines[cur_start:i])
|
||||
cur_func, cur_start = m.group(1), i - 1
|
||||
if cur_func is not None:
|
||||
_classify(results, markers, rel, cur_func, lines[cur_start:])
|
||||
return results
|
||||
|
||||
|
||||
def _classify(results, markers, rel, func, seg):
|
||||
"""按 test_ 函数分块,统计:(a) 函数内总 assert 数;
|
||||
(b) 与意图标记词邻近(±WINDOW 行)的 assert 数 —— 这才是"该意图被真正断言"的口径。"""
|
||||
seg_text = "\n".join(seg)
|
||||
WINDOW = 3
|
||||
marker_lines = set()
|
||||
for idx, line in enumerate(seg):
|
||||
for m in markers:
|
||||
if m in line:
|
||||
marker_lines.add(idx)
|
||||
total_asserts = 0
|
||||
intent_asserts = 0
|
||||
for idx, line in enumerate(seg):
|
||||
if re.search(r"\bassert\b", line):
|
||||
total_asserts += 1
|
||||
if any(abs(idx - ml) <= WINDOW for ml in marker_lines):
|
||||
intent_asserts += 1
|
||||
for m in markers:
|
||||
if m in seg_text:
|
||||
results[m].append({"file": rel, "func": func,
|
||||
"asserts": total_asserts,
|
||||
"intent_asserts": intent_asserts})
|
||||
|
||||
|
||||
def run(intents_path, app_dir, tests_dir, out_dir):
|
||||
intents = json.loads(Path(intents_path).read_text(encoding="utf-8"))
|
||||
rows = []
|
||||
for it in intents:
|
||||
src_markers = it.get("source_markers", [])
|
||||
test_markers = it.get("test_markers") or src_markers
|
||||
shits, sfiles = (scan_source(app_dir, src_markers)
|
||||
if src_markers else ({}, set()))
|
||||
thits = scan_tests(tests_dir, test_markers)
|
||||
test_refs = []
|
||||
for lst in thits.values():
|
||||
test_refs.extend(lst)
|
||||
seen, uniq = set(), []
|
||||
for r in test_refs:
|
||||
k = (r["file"], r["func"])
|
||||
if k in seen:
|
||||
continue
|
||||
seen.add(k)
|
||||
uniq.append(r)
|
||||
source_present = bool(sfiles)
|
||||
covered = len(uniq) > 0
|
||||
real_asserts = sum(r["intent_asserts"] for r in uniq)
|
||||
if covered and real_asserts > 0:
|
||||
strength = "强(邻近有断言)"
|
||||
elif covered:
|
||||
strength = "弱(仅引用无邻近断言)"
|
||||
else:
|
||||
strength = "未覆盖"
|
||||
rows.append({
|
||||
"id": it.get("id"),
|
||||
"name": it.get("name"),
|
||||
"desc": it.get("desc", ""),
|
||||
"source_present": source_present,
|
||||
"source_files": sorted(sfiles),
|
||||
"covered": covered,
|
||||
"strength": strength,
|
||||
"assert_count": real_asserts,
|
||||
"test_refs": uniq,
|
||||
})
|
||||
out_dir = Path(out_dir)
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
md = _render_md(rows)
|
||||
md_path = out_dir / "report.md"
|
||||
jsn_path = out_dir / "report.json"
|
||||
md_path.write_text(md, encoding="utf-8")
|
||||
jsn_path.write_text(json.dumps(rows, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8")
|
||||
return rows, md_path, jsn_path
|
||||
|
||||
|
||||
def _render_md(rows):
|
||||
lines = ["# 核心设计意图覆盖核验报告", "",
|
||||
f"> 生成方式:只读静态扫描,未 import / 未修改 CostReview 任何文件。", ""]
|
||||
covered = sum(1 for r in rows if r["covered"])
|
||||
lines.append(f"总意图数:**{len(rows)}** | 已覆盖:**{covered}** | 未覆盖:**{len(rows) - covered}**")
|
||||
lines.append("")
|
||||
for r in rows:
|
||||
tag = "✅" if r["covered"] else "❌"
|
||||
lines.append(f"## [{tag}] {r['id']} {r['name']}")
|
||||
lines.append(f"- 描述:{r['desc']}")
|
||||
lines.append(f"- 源码存在:{r['source_present']} | 测试覆盖:{r['covered']} | "
|
||||
f"强度:**{r['strength']}** | 邻近断言数:{r['assert_count']}")
|
||||
if r["source_files"]:
|
||||
lines.append(f"- 源码命中文件:{', '.join(r['source_files'])}")
|
||||
if r["test_refs"]:
|
||||
lines.append("- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):")
|
||||
for t in r["test_refs"]:
|
||||
lines.append(f" - `{t['file']}::{t['func']}` (intent={t['intent_asserts']} / total={t['asserts']})")
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
argv = argv or sys.argv[1:]
|
||||
intents_path, app_dir = DEFAULT_INTENTS, APP_DEFAULT
|
||||
tests_dir, out_dir = TESTS_DEFAULT, OUT_DEFAULT
|
||||
i = 0
|
||||
while i < len(argv):
|
||||
a = argv[i]
|
||||
if a in ("-h", "--help"):
|
||||
print(__doc__)
|
||||
return 0
|
||||
if a == "--intents":
|
||||
intents_path = argv[i + 1]; i += 2; continue
|
||||
if a == "--app":
|
||||
app_dir = argv[i + 1]; i += 2; continue
|
||||
if a == "--tests":
|
||||
tests_dir = argv[i + 1]; i += 2; continue
|
||||
if a == "--out":
|
||||
out_dir = argv[i + 1]; i += 2; continue
|
||||
i += 1
|
||||
if not os.path.isabs(intents_path):
|
||||
intents_path = str(BASE / intents_path)
|
||||
rows, md_path, jsn_path = run(intents_path, app_dir, tests_dir, out_dir)
|
||||
print(f"报告已生成:\n {md_path}\n {jsn_path}")
|
||||
print(f"已覆盖 {sum(1 for r in rows if r['covered'])}/{len(rows)} 条设计意图")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
58
test/core_intent_coverage/intents.json
Normal file
58
test/core_intent_coverage/intents.json
Normal file
@@ -0,0 +1,58 @@
|
||||
[
|
||||
{
|
||||
"id": "INT-01",
|
||||
"name": "价格导入:一个块=一个批次",
|
||||
"desc": "HTML 一个顶层块=一批次;期次优先级 块名→文件名→弹框;批次名 多块用块名/单块用弹框名。",
|
||||
"source_markers": ["x_imported_at", "批次", "块名", "一个块"],
|
||||
"test_markers": ["批次", "块", "import"]
|
||||
},
|
||||
{
|
||||
"id": "INT-02",
|
||||
"name": "工料机/价格分表存储 + 判批次用 kind",
|
||||
"desc": "x_rows_lme 只存工料机数,x_rows_price 只存价格数;判断批次有没有工料机一律用 kind='project',永远别用行数。",
|
||||
"source_markers": ["x_rows_lme", "x_rows_price", "kind='project'", "kind=\"project\""],
|
||||
"test_markers": ["x_rows_lme", "x_rows_price", "kind"]
|
||||
},
|
||||
{
|
||||
"id": "INT-03",
|
||||
"name": "会话↔后台批次同源绑定",
|
||||
"desc": "靠 batches.x_src_hash == sessions.src_name(都是 sha256_原名)只认同源文件;工作台只读,绑定/改绑只在后台。",
|
||||
"source_markers": ["x_src_hash", "src_name"],
|
||||
"test_markers": ["x_src_hash", "src_name"]
|
||||
},
|
||||
{
|
||||
"id": "INT-04",
|
||||
"name": "列表排序口径",
|
||||
"desc": "排序 x_period_end_m DESC, x_imported_at DESC, id DESC(期次最新最前)。",
|
||||
"source_markers": ["x_period_end_m", "x_imported_at"],
|
||||
"test_markers": ["x_period_end_m", "x_imported_at", "排序"]
|
||||
},
|
||||
{
|
||||
"id": "INT-05",
|
||||
"name": "序号递减口径",
|
||||
"desc": "序号 seq = total - ((page-1)*size + i)(首行=总数递减)。",
|
||||
"source_markers": ["seq", "page", "size"],
|
||||
"test_markers": ["seq", "page", "size"]
|
||||
},
|
||||
{
|
||||
"id": "INT-06",
|
||||
"name": "询价附件项目专属",
|
||||
"desc": "询价附件=项目专属,lmes 与 prices 零交叉,附件挂 lmes 天然只落项目;代码显式断言 kind='project'。",
|
||||
"source_markers": ["kind='project'", "lmes", "询价附件"],
|
||||
"test_markers": ["询价", "附件", "lmes"]
|
||||
},
|
||||
{
|
||||
"id": "INT-07",
|
||||
"name": "数据源字典口径",
|
||||
"desc": "dict_region + dict_org(cat: publisher|builder);录入类下拉只取字典,过滤类下拉取 字典∪库里实际值。",
|
||||
"source_markers": ["dict_region", "dict_org", "publisher", "builder"],
|
||||
"test_markers": ["dict_region", "dict_org"]
|
||||
},
|
||||
{
|
||||
"id": "INT-08",
|
||||
"name": "信息价期次优先级",
|
||||
"desc": "价格导入期次优先级 块名→文件名→弹框;一个块=一个批次。",
|
||||
"source_markers": ["期次", "弹框", "块名"],
|
||||
"test_markers": ["期次", "弹框"]
|
||||
}
|
||||
]
|
||||
1070
test/core_intent_coverage/out/report.json
Normal file
1070
test/core_intent_coverage/out/report.json
Normal file
File diff suppressed because it is too large
Load Diff
190
test/core_intent_coverage/out/report.md
Normal file
190
test/core_intent_coverage/out/report.md
Normal file
@@ -0,0 +1,190 @@
|
||||
# 核心设计意图覆盖核验报告
|
||||
|
||||
> 生成方式:只读静态扫描,未 import / 未修改 CostReview 任何文件。
|
||||
|
||||
总意图数:**8** | 已覆盖:**7** | 未覆盖:**1**
|
||||
|
||||
## [✅] INT-01 价格导入:一个块=一个批次
|
||||
- 描述:HTML 一个顶层块=一批次;期次优先级 块名→文件名→弹框;批次名 多块用块名/单块用弹框名。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:104
|
||||
- 源码命中文件:core\export_cos.py, core\export_xlsx.py, core\import_job.py, core\match.py, core\price_html.py, core\price_xlsx.py, core\session_job.py, server\api_server.py, server\mcp_server.py, tests\test_api_p1.py, tests\test_api_upgrade.py, tests\test_export_structure.py, tests\test_kw_tier.py, tests\test_lme_uw_card.py, tests\test_match_tiers.py, tests\test_norm_op.py, tests\test_price_redesign.py, tests\test_unit_core.py, tools\backfill_lme_lib.py, tools\check_parity.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\rebuild_batch_db.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_p1.py::test_inq_lifecycle` (intent=3 / total=12)
|
||||
- `test_api_p1.py::test_adopt_flow` (intent=1 / total=8)
|
||||
- `test_api_p1.py::test_clear_mock_keeps_real` (intent=2 / total=3)
|
||||
- `test_api_p1.py::test_price_import_rejects_empty_class` (intent=1 / total=1)
|
||||
- `test_api_p1.py::test_price_import_single_and_dup` (intent=8 / total=8)
|
||||
- `test_api_upgrade.py::test_upgrade_via_admin_api` (intent=2 / total=4)
|
||||
- `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=1 / total=3)
|
||||
- `test_api_upgrade.py::test_upgrade_price_batch_rejected` (intent=2 / total=2)
|
||||
- `test_export_structure.py::test_resource_pseudo_norm_skipped_on_import` (intent=2 / total=3)
|
||||
- `test_export_structure.py::test_coef_unit_prefix_no_double_count` (intent=1 / total=4)
|
||||
- `test_kw_tier.py::test_strict_first_loose_last` (intent=0 / total=1)
|
||||
- `test_kw_tier.py::test_rank_combined_with_filters` (intent=2 / total=2)
|
||||
- `test_match_tiers.py::test_disabled_batch_excluded` (intent=1 / total=1)
|
||||
- `test_match_tiers.py::test_period_distance_sort_and_window` (intent=3 / total=3)
|
||||
- `test_norm_op.py::test_norm_ntdel_export_omits` (intent=4 / total=8)
|
||||
- `test_price_redesign.py::test_dirs_tree_and_counts` (intent=2 / total=9)
|
||||
- `test_price_redesign.py::test_prices_filter_and_export` (intent=8 / total=11)
|
||||
- `test_unit_core.py::test_price_html_parse_and_records` (intent=4 / total=8)
|
||||
- `test_unit_core.py::test_price_xlsx_parse_and_template` (intent=5 / total=10)
|
||||
- `test_api_group.py::test_group_conservation_and_name_layer` (intent=4 / total=9)
|
||||
- `test_export_structure.py::test_new_bill_full_structure_cos` (intent=0 / total=12)
|
||||
- `test_unit_core.py::test_clean_attr_strips_and_guard` (intent=3 / total=3)
|
||||
- `test_unit_core.py::test_guess_period` (intent=4 / total=4)
|
||||
- `test_unit_core.py::test_price_html_rejects_non_data` (intent=1 / total=2)
|
||||
- `test_api_p0.py::test_gate_off_and_status` (intent=0 / total=2)
|
||||
- `test_api_p0.py::test_import_project_ok` (intent=3 / total=10)
|
||||
- `test_api_p0.py::test_import_encrypted_rejected` (intent=1 / total=1)
|
||||
- `test_api_p0.py::test_import_unknown_rejected` (intent=1 / total=1)
|
||||
- `test_api_p0.py::test_import_xml_rejected` (intent=1 / total=1)
|
||||
- `test_api_p0.py::test_import_outside_path_rejected` (intent=1 / total=1)
|
||||
- `test_api_p0.py::test_import_dup_confirm_then_force` (intent=3 / total=3)
|
||||
- `test_api_p0.py::test_search_bill_self_excluded` (intent=0 / total=4)
|
||||
- `test_api_p0.py::test_search_lme` (intent=0 / total=2)
|
||||
- `test_api_p0.py::test_hist_search_kw` (intent=0 / total=4)
|
||||
- `test_api_p0.py::test_delete_batch_cascade` (intent=1 / total=6)
|
||||
- `test_api_p0.py::test_batch_row_edit_whitelist` (intent=0 / total=3)
|
||||
- `test_api_p1.py::test_attach_lifecycle` (intent=1 / total=10)
|
||||
- `test_api_p1.py::test_enabled_toggle` (intent=1 / total=3)
|
||||
- `test_api_p1.py::test_price_xlsx_import` (intent=2 / total=12)
|
||||
- `test_api_p1.py::test_dict_roundtrip` (intent=0 / total=7)
|
||||
- `test_export_ext.py::test_ext_follows_source` (intent=1 / total=1)
|
||||
- `test_export_structure.py::test_new_bill_top_anchor_position` (intent=1 / total=4)
|
||||
- `test_export_structure.py::test_adoption_carries_express_adjustment` (intent=1 / total=6)
|
||||
- `test_license_import.py::test_repo_pinned_keys_prod_key_self_consistent` (intent=0 / total=4)
|
||||
- `test_license_import.py::test_import_validate_matrix` (intent=2 / total=2)
|
||||
- `test_license_import.py::test_import_error_never_echoes_content` (intent=3 / total=3)
|
||||
- `test_license_import.py::test_import_loopback_http_dev_only` (intent=2 / total=2)
|
||||
- `test_license_import.py::test_import_happy_path` (intent=3 / total=3)
|
||||
- `test_license_import.py::test_import_conflict_needs_explicit_confirm` (intent=5 / total=5)
|
||||
- `test_license_import.py::test_import_same_instance_no_confirm_needed` (intent=1 / total=1)
|
||||
- `test_license_import.py::test_import_high_water_preserved` (intent=2 / total=2)
|
||||
- `test_license_verify.py::test_revoked_key` (intent=0 / total=0)
|
||||
- `test_license_verify.py::test_non_p256_key_rejected_at_ring_build` (intent=0 / total=0)
|
||||
- `test_lme_price.py::test_export_recode_renames_mother_and_rebuilds_children` (intent=0 / total=3)
|
||||
- `test_lme_price.py::test_export_recode_childless_renames_only` (intent=0 / total=2)
|
||||
- `test_norm_op.py::test_adopt_gcl_default_and_price_overwrite` (intent=0 / total=7)
|
||||
- `test_norm_op.py::test_qty_export_follows_source_pattern` (intent=2 / total=6)
|
||||
- `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
|
||||
- `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
|
||||
- `test_price_redesign.py::test_dir_add_rename_move_seq` (intent=0 / total=11)
|
||||
- `test_price_redesign.py::test_dir_del_rows_fall_uncat` (intent=0 / total=4)
|
||||
- `test_price_redesign.py::test_row_crud_and_hash` (intent=1 / total=11)
|
||||
- `test_unit_core.py::test_sniff` (intent=0 / total=1)
|
||||
|
||||
## [✅] INT-02 工料机/价格分表存储 + 判批次用 kind
|
||||
- 描述:x_rows_lme 只存工料机数,x_rows_price 只存价格数;判断批次有没有工料机一律用 kind='project',永远别用行数。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:50
|
||||
- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, server\api_server.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_price_redesign.py, tools\backfill_lme_lib.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\test_parse_std.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_p0.py::test_import_project_ok` (intent=4 / total=10)
|
||||
- `test_api_p1.py::test_price_xlsx_import` (intent=4 / total=12)
|
||||
- `test_api_p1.py::test_price_import_single_and_dup` (intent=8 / total=8)
|
||||
- `test_price_redesign.py::test_row_crud_and_hash` (intent=5 / total=11)
|
||||
- `test_api_p0.py::test_import_dup_confirm_then_force` (intent=2 / total=3)
|
||||
- `test_api_p1.py::test_inq_lifecycle` (intent=1 / total=12)
|
||||
- `test_api_p1.py::test_clear_mock_keeps_real` (intent=0 / total=3)
|
||||
- `test_api_p1.py::test_price_import_rejects_empty_class` (intent=1 / total=1)
|
||||
- `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=3 / total=3)
|
||||
- `test_api_upgrade.py::test_upgrade_price_batch_rejected` (intent=1 / total=2)
|
||||
- `test_export_structure.py::test_new_bill_top_anchor_position` (intent=1 / total=4)
|
||||
- `test_export_structure.py::test_adoption_carries_express_adjustment` (intent=2 / total=6)
|
||||
- `test_export_structure.py::test_resource_pseudo_norm_skipped_on_import` (intent=1 / total=3)
|
||||
- `test_export_structure.py::test_coef_unit_prefix_no_double_count` (intent=0 / total=4)
|
||||
- `test_kw_tier.py::test_rank_combined_with_filters` (intent=1 / total=2)
|
||||
- `test_license_import.py::test_repo_pinned_keys_prod_key_self_consistent` (intent=1 / total=4)
|
||||
- `test_license_verify.py::test_package_vectors_canonical_matches` (intent=2 / total=2)
|
||||
- `test_lme_price.py::test_merge_child_group_repoints_unit_mothers_and_replaces_children` (intent=0 / total=9)
|
||||
- `test_lme_price.py::test_http_lme_price_end_to_end` (intent=1 / total=10)
|
||||
- `test_norm_op.py::test_norm_unadopt_hard_delete` (intent=0 / total=6)
|
||||
- `test_norm_res_name.py::test_collision_row_takes_summary_whole` (intent=1 / total=2)
|
||||
- `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
|
||||
- `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
|
||||
- `test_price_redesign.py::test_prices_filter_and_export` (intent=1 / total=11)
|
||||
- `test_unit_core.py::test_sim_weighted_token_veto` (intent=0 / total=2)
|
||||
- `test_unit_core.py::test_lme_list_where_kind_cast` (intent=0 / total=1)
|
||||
- `test_unit_core.py::test_parse_std_structure` (intent=9 / total=14)
|
||||
|
||||
## [✅] INT-03 会话↔后台批次同源绑定
|
||||
- 描述:靠 batches.x_src_hash == sessions.src_name(都是 sha256_原名)只认同源文件;工作台只读,绑定/改绑只在后台。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:4
|
||||
- 源码命中文件:core\export_cos.py, core\import_job.py, core\match.py, core\session_job.py, server\api_server.py, tests\test_api_upgrade.py, tests\test_export_ext.py, tests\test_kw_tier.py, tests\test_lme_proj_source.py, tests\test_lme_uw_card.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_source_guards.py, tests\test_stopwords.py, tools\backfill_lme_lib.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\test_parse_std.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_upgrade.py::test_upgrade_via_audit_open` (intent=0 / total=3)
|
||||
- `test_export_ext.py::test_ext_follows_source` (intent=1 / total=1)
|
||||
- `test_source_guards.py::test_reopen_with_new_file_syncs_src_and_remarks` (intent=3 / total=9)
|
||||
|
||||
## [✅] INT-04 列表排序口径
|
||||
- 描述:排序 x_period_end_m DESC, x_imported_at DESC, id DESC(期次最新最前)。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:15
|
||||
- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\search_demo.py, server\api_server.py, tests\test_api_p1.py, tests\test_kw_tier.py, tests\test_match_tiers.py, tests\test_stopwords.py, tools\gen_price_mock.py, tools\gen_project_mock.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_p1.py::test_price_xlsx_import` (intent=3 / total=12)
|
||||
- `test_api_p1.py::test_price_import_single_and_dup` (intent=4 / total=8)
|
||||
- `test_api_group.py::test_group_conservation_and_name_layer` (intent=4 / total=9)
|
||||
- `test_group_order.py::test_kw_group_mixed_by_tsum` (intent=1 / total=4)
|
||||
- `test_kw_tier.py::test_loose_flag_matches_rank` (intent=0 / total=1)
|
||||
- `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=3 / total=5)
|
||||
|
||||
## [✅] INT-05 序号递减口径
|
||||
- 描述:序号 seq = total - ((page-1)*size + i)(首行=总数递减)。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:16
|
||||
- 源码命中文件:core\export_cos.py, core\export_xlsx.py, core\import_job.py, core\match.py, core\price_xlsx.py, core\session_job.py, server\api_server.py, server\license_client\gate.py, shell.py, tests\test_api_group.py, tests\test_group_order.py, tests\test_grp_units.py, tests\test_kw_tier.py, tests\test_lme_price.py, tests\test_lme_proj_source.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_perf_baseline.py, tests\test_price_redesign.py, tests\test_stopwords.py, tools\check_parity.py, tools\gen_price_mock.py, tools\health_check.py, tools\purge_batches.py, tools\rebuild_batch_db.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_group.py::test_group_keyword_layer` (intent=0 / total=3)
|
||||
- `test_group_order.py::test_kw_group_mixed_by_tsum` (intent=0 / total=4)
|
||||
- `test_lme_price.py::test_merge_child_group_repoints_unit_mothers_and_replaces_children` (intent=3 / total=9)
|
||||
- `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=1 / total=5)
|
||||
- `test_price_redesign.py::test_dirs_tree_and_counts` (intent=1 / total=9)
|
||||
- `test_price_redesign.py::test_dir_add_rename_move_seq` (intent=2 / total=11)
|
||||
- `test_kw_tier.py::test_pagination_rank_stable` (intent=2 / total=2)
|
||||
- `test_perf_baseline.py::test_large_project_import_and_open` (intent=1 / total=3)
|
||||
- `test_perf_baseline.py::test_read_not_starved_under_write` (intent=0 / total=1)
|
||||
- `test_price_redesign.py::test_prices_filter_and_export` (intent=4 / total=11)
|
||||
- `test_stopwords.py::test_stop_before_limit_pagination` (intent=2 / total=2)
|
||||
|
||||
## [✅] INT-06 询价附件项目专属
|
||||
- 描述:询价附件=项目专属,lmes 与 prices 零交叉,附件挂 lmes 天然只落项目;代码显式断言 kind='project'。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:34
|
||||
- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\search_demo.py, core\session_job.py, server\api_server.py, tests\api_harness.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_lme_price.py, tests\test_lme_proj_source.py, tests\test_lme_uw_card.py, tests\test_norm_res_name.py, tests\test_perf_baseline.py, tests\test_unit_core.py, tools\backfill_lme_lib.py, tools\check_parity.py, tools\gen_price_mock.py, tools\gen_project_mock.py, tools\purge_batches.py, tools\rebuild_batch_db.py, tools\test_parse_std.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_p1.py::test_attach_lifecycle` (intent=0 / total=10)
|
||||
- `test_api_p1.py::test_inq_lifecycle` (intent=11 / total=12)
|
||||
- `test_api_p1.py::test_adopt_flow` (intent=3 / total=8)
|
||||
- `test_price_redesign.py::test_prices_filter_and_export` (intent=3 / total=11)
|
||||
- `test_api_p0.py::test_audit_open_reuse_and_remark` (intent=2 / total=9)
|
||||
- `test_api_p0.py::test_delete_batch_cascade` (intent=5 / total=6)
|
||||
- `test_lme_price.py::test_raw_uw_rows_are_nine_wide_with_taxrate_at_7` (intent=0 / total=4)
|
||||
- `test_lme_price.py::test_raw_proj_fallback_nine_wide_taxrate_at_7` (intent=0 / total=4)
|
||||
- `test_lme_price.py::test_raw_proj_fallback_without_taxrate_column` (intent=0 / total=1)
|
||||
- `test_lme_price.py::test_raw_uw_agg_fallback_nine_wide_taxrate_at_7` (intent=0 / total=4)
|
||||
- `test_lme_proj_source.py::test_migrate_rekeys_events_and_gate` (intent=0 / total=4)
|
||||
- `test_norm_res_name.py::test_name_prefers_unit_summary` (intent=2 / total=2)
|
||||
- `test_norm_res_name.py::test_legacy_chain_intact` (intent=1 / total=1)
|
||||
- `test_norm_res_name.py::test_prices_filled_from_summary_when_missing` (intent=0 / total=1)
|
||||
- `test_norm_res_name.py::test_collision_row_takes_summary_whole` (intent=0 / total=2)
|
||||
- `test_perf_baseline.py::test_large_project_import_and_open` (intent=0 / total=3)
|
||||
- `test_unit_core.py::test_parse_std_structure` (intent=7 / total=14)
|
||||
|
||||
## [❌] INT-07 数据源字典口径
|
||||
- 描述:dict_region + dict_org(cat: publisher|builder);录入类下拉只取字典,过滤类下拉取 字典∪库里实际值。
|
||||
- 源码存在:True | 测试覆盖:False | 强度:**未覆盖** | 邻近断言数:0
|
||||
- 源码命中文件:core\match.py, server\api_server.py, tests\test_api_p1.py, tests\test_api_upgrade.py, tests\test_kw_tier.py, tests\test_price_redesign.py, tests\test_stopwords.py, tools\gen_price_mock.py
|
||||
|
||||
## [✅] INT-08 信息价期次优先级
|
||||
- 描述:价格导入期次优先级 块名→文件名→弹框;一个块=一个批次。
|
||||
- 源码存在:True | 测试覆盖:True | 强度:**强(邻近有断言)** | 邻近断言数:15
|
||||
- 源码命中文件:core\export_xlsx.py, core\import_job.py, core\match.py, core\price_html.py, core\price_xlsx.py, core\search_demo.py, core\session_job.py, server\api_server.py, tests\api_harness.py, tests\test_api_p0.py, tests\test_api_p1.py, tests\test_kw_tier.py, tests\test_lme_price.py, tests\test_match_tiers.py, tests\test_norm_res_name.py, tests\test_unit_core.py, tools\check_parity.py
|
||||
- 测试引用(intent=与本意图邻近的断言数 / total=函数内总断言数):
|
||||
- `test_api_p0.py::test_batch_row_edit_whitelist` (intent=3 / total=3)
|
||||
- `test_api_p1.py::test_price_xlsx_import` (intent=3 / total=12)
|
||||
- `test_api_p1.py::test_price_import_single_and_dup` (intent=3 / total=8)
|
||||
- `test_kw_tier.py::test_strict_first_loose_last` (intent=0 / total=1)
|
||||
- `test_kw_tier.py::test_pagination_rank_stable` (intent=0 / total=2)
|
||||
- `test_match_tiers.py::test_period_distance_sort_and_window` (intent=3 / total=3)
|
||||
- `test_unit_core.py::test_sniff` (intent=1 / total=1)
|
||||
- `test_lme_price.py::test_sub_composition_rows_are_editable` (intent=1 / total=2)
|
||||
- `test_lme_price.py::test_merge_still_registers_codes_after_refactor` (intent=1 / total=3)
|
||||
- `test_lme_price.py::test_merge_group_includes_child_rows_with_flag` (intent=0 / total=3)
|
||||
- `test_norm_res_name.py::test_merge_groups_keep_composite_rows` (intent=0 / total=5)
|
||||
10
test/core_intent_coverage/pyproject.toml
Normal file
10
test/core_intent_coverage/pyproject.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[project]
|
||||
name = "core-intent-coverage"
|
||||
version = "0.1.0"
|
||||
description = "只读静态核验:核心设计意图是否被 p0/p1 测试真正断言覆盖(零污染,不 import 工程)"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = []
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=61"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
10
test/core_intent_coverage/run.py
Normal file
10
test/core_intent_coverage/run.py
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""入口:python run.py [--app ...] [--tests ...] [--intents ...] [--out ...]"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from checker import main # noqa: E402
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user