"""End-to-end OCR tests against the synthetic receipt renderer. Skipped automatically if the tesseract binary isn't installed. """ from __future__ import annotations import shutil import sys from pathlib import Path import pytest pytestmark = pytest.mark.skipif( shutil.which("tesseract") is None, reason="tesseract binary not installed" ) sys.path.insert(0, str(Path(__file__).parent.parent / "sample_data")) def _receipt_image(index: int): from make_receipt_video import RECEIPTS, make_receipt_image return make_receipt_image(RECEIPTS[index]) def test_home_depot_receipt_fields(): from paperpod.ocr.extract import run_ocr result = run_ocr(_receipt_image(0)) assert result.date == "2023-03-14" assert result.total == "81.52" assert "HOME DEPOT" in (result.vendor or "") def test_metro_receipt_fields(): from paperpod.ocr.extract import run_ocr result = run_ocr(_receipt_image(1)) assert result.date == "2023-06-02" assert result.total == "30.63" assert "METRO" in (result.vendor or "") def test_petro_canada_receipt_fields(): from paperpod.ocr.extract import run_ocr result = run_ocr(_receipt_image(2)) assert result.date == "2023-08-19" assert result.total == "65.10" assert "PETRO" in (result.vendor or "")