v1: executing-plans 模式生成,54 文件 1320 行 Python
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import sys, os, json
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
||||
from pathlib import Path
|
||||
from report.generator import ReportGenerator
|
||||
from data.diff_result import VerificationRun, FieldResult
|
||||
|
||||
|
||||
def test_json_output(tmp_path):
|
||||
vr = VerificationRun(program="BILL-CALC", status="PASS", exit_code=0,
|
||||
field_results=[FieldResult(field_name="BR-AMT", status="PASS")])
|
||||
gen = ReportGenerator()
|
||||
path = gen.generate_json(vr, tmp_path / "result.json")
|
||||
data = json.loads(path.read_text())
|
||||
assert data["program"] == "BILL-CALC"
|
||||
assert data["status"] == "PASS"
|
||||
|
||||
|
||||
def test_html_output(tmp_path):
|
||||
vr = VerificationRun(program="TEST", status="MISMATCH",
|
||||
field_results=[FieldResult(field_name="F1", status="MISMATCH")])
|
||||
gen = ReportGenerator()
|
||||
path = gen.generate_html(vr, tmp_path / "report.html")
|
||||
assert path.exists()
|
||||
html = path.read_text()
|
||||
assert "MISMATCH" in html
|
||||
assert "F1" in html
|
||||
|
||||
|
||||
def test_machine_json(tmp_path):
|
||||
vr = VerificationRun(program="TEST", status="PASS", exit_code=0)
|
||||
gen = ReportGenerator()
|
||||
path = gen.generate_machine_json(vr, tmp_path / "machine.json")
|
||||
data = json.loads(path.read_text())
|
||||
assert data["exit_code"] == 0
|
||||
|
||||
|
||||
def test_suggestion_in_report(tmp_path):
|
||||
fr = FieldResult(field_name="BR-AMT", status="MISMATCH",
|
||||
suggestion="Check rounding_mode: TRUNCATE vs HALF_UP")
|
||||
vr = VerificationRun(program="TEST", status="MISMATCH", field_results=[fr])
|
||||
gen = ReportGenerator()
|
||||
path = gen.generate_json(vr, tmp_path / "result.json")
|
||||
data = json.loads(path.read_text())
|
||||
assert "suggestion" in data["field_results"][0]
|
||||
Reference in New Issue
Block a user