45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
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]
|