75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
报表模块端到端验收自检(无需启动浏览器)。
|
|
|
|
运行:cd backend-fastapi && python -m online_dev.report_manager.acceptance_e2e
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from online_dev.report_manager.engine.test_golden import test_all_golden_fixtures
|
|
|
|
|
|
def _check_routes_registered() -> None:
|
|
root = Path(__file__).parent
|
|
sources = [
|
|
(root / "api.py").read_text(encoding="utf-8"),
|
|
(root / "data_api.py").read_text(encoding="utf-8"),
|
|
]
|
|
blob = "\n".join(sources)
|
|
required = [
|
|
'"/list"',
|
|
'"/save"',
|
|
'"/{version_id}/preview"',
|
|
'"/preview-template"',
|
|
'"/export-excel/template"',
|
|
'"/export-pdf/template"',
|
|
'"/import-excel"',
|
|
'"/query-list/{template_id}"',
|
|
'"/{template_id}/publish"',
|
|
]
|
|
missing = [p for p in required if p not in blob]
|
|
if missing:
|
|
raise AssertionError(f"missing route decorators for: {missing}")
|
|
|
|
|
|
def _check_jnpf_db_fixtures() -> None:
|
|
fixtures_dir = Path(__file__).parent / "engine" / "fixtures"
|
|
names = [
|
|
"golden_jnpf_db_user_list.json",
|
|
"golden_jnpf_db_user_group.json",
|
|
"golden_jnpf_db_user_matrix.json",
|
|
]
|
|
for name in names:
|
|
path = fixtures_dir / name
|
|
if not path.is_file():
|
|
raise AssertionError(f"missing JNPF DB fixture: {name}")
|
|
|
|
|
|
def main() -> int:
|
|
print("1/3 route registration …")
|
|
_check_routes_registered()
|
|
print(" ok")
|
|
|
|
print("2/3 JNPF DB golden fixtures …")
|
|
_check_jnpf_db_fixtures()
|
|
print(" ok (3 fixtures)")
|
|
|
|
print("3/3 golden transform regression …")
|
|
test_all_golden_fixtures()
|
|
count = len(list((Path(__file__).parent / "engine" / "fixtures").glob("golden_*.json")))
|
|
print(f" ok ({count} fixtures)")
|
|
|
|
print("\nManual E2E (browser):")
|
|
print(" - 新建报表 → 设计 → 保存 → 发布版本")
|
|
print(" - 发布菜单 → 运行时填写查询 → 预览")
|
|
print(" - Excel / PDF 导出、浏览器打印(>100 张图告警)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|