新增省份: 内蒙古/广西/西藏/宁夏
新增内容:
- 4 个新 JSON 文件 (neimenggu/guangxi/xizang/ningxia.json)
- 每省 8 段 score_ranges, 每段 5 recs × 2 alts
- 全部达 high (conf=0.82, recs=40, alts=80, 3 层分数带)
- trusted_sources 含国家级+省级官方入口
loader.py 扩展:
- PROVINCE_FILE_MAP 新增 4 自治区映射
- 全国 31 省口径正式建立
测试同步:
- test_crowd_db_data_quality.py: HIGH_TRUST_PROVINCES 扩展到 31 省
- test_provenance_query.py: 全部省份列表追加 4 自治区
- test_provenance.py: 总数期望 27 → 31
- test_quality_summary.py: total_provinces 27 → 31
SCHEMA.md §7: 当前代码兼容口径从 27 省 → 31 省
文档真相源同步:
- CURRENT_STATE.md: 31 high / 0 usable / 0 skeleton
- NATIONALIZATION: Stage 4 历史轨迹 + 口径边界更新
验证:
- ruff: All checks passed
- mypy: Success, no issues in 16 source files
- pytest crowd_db: 147 passed
- consistency: ✅ high=31 usable=0 low=0 skeleton=0
当前分布: 31 high / 0 usable / 0 skeleton (全国 31 省全部达 high)
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from data.crowd_db.loader import CrowdDBLoader
|
|
|
|
|
|
def test_build_quality_summary_returns_expected_shape():
|
|
from data.crowd_db.quality_summary import build_quality_summary
|
|
|
|
summary = build_quality_summary(CrowdDBLoader(warn_low_confidence=False))
|
|
|
|
assert summary["total_provinces"] == 31
|
|
assert summary["by_quality_level"]
|
|
assert set(summary["by_quality_level"]).issuperset({"high", "usable", "skeleton"})
|
|
assert len(summary["provinces"]) == 31
|
|
first = summary["provinces"][0]
|
|
assert set(first).issuperset({
|
|
"province",
|
|
"confidence",
|
|
"quality_level",
|
|
"quality_label",
|
|
"data_year",
|
|
"source_type",
|
|
})
|
|
hunan = next(p for p in summary["provinces"] if p["province"] == "湖南")
|
|
assert hunan["quality_level"] == "high"
|
|
|
|
|
|
def test_quality_summary_cli_human_output(capsys):
|
|
from data.crowd_db.quality_summary import main
|
|
|
|
code = main(["--human"])
|
|
captured = capsys.readouterr()
|
|
assert code == 0
|
|
assert "province_count: 31" in captured.out
|
|
assert "quality_counts:" in captured.out
|
|
assert "湖南" in captured.out
|