From 9d53c452ec0d91525bd8fb058cee1f4abfd76dda Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Sat, 14 Dec 2024 11:14:07 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=94=20=20Test=20that=20CLI=20produces=20a?= =?UTF-8?q?=20complete=20HTML=20report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...json.py => test_integ_cli_valid_report.py} | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) rename src/dinglehopper/tests/{test_integ_cli_valid_json.py => test_integ_cli_valid_report.py} (64%) diff --git a/src/dinglehopper/tests/test_integ_cli_valid_json.py b/src/dinglehopper/tests/test_integ_cli_valid_report.py similarity index 64% rename from src/dinglehopper/tests/test_integ_cli_valid_json.py rename to src/dinglehopper/tests/test_integ_cli_valid_report.py index 6cbfa0c..fed0d28 100644 --- a/src/dinglehopper/tests/test_integ_cli_valid_json.py +++ b/src/dinglehopper/tests/test_integ_cli_valid_report.py @@ -1,4 +1,5 @@ import json +import re import pytest @@ -40,3 +41,25 @@ def test_cli_json_cer_is_infinity(tmp_path): with open("report.json", "r") as jsonf: j = json.load(jsonf) assert j["cer"] == pytest.approx(float("inf")) + + +@pytest.mark.integration +def test_cli_html(tmp_path): + """Test that the cli/process() yields complete HTML report""" + + with working_directory(tmp_path): + with open("gt.txt", "w") as gtf: + gtf.write("AAAAA") + with open("ocr.txt", "w") as ocrf: + ocrf.write("AAAAB") + + process("gt.txt", "ocr.txt", "report") + + with open("report.html", "r") as htmlf: + html_report = htmlf.read() + print(html_report) + + assert re.search(r"CER: 0\.\d+", html_report) + assert re.search(r"WER: 1\.0", html_report) + assert len(re.findall("gt.*cdiff", html_report)) == 1 + assert len(re.findall("gt.*wdiff", html_report)) == 1