from cv_analysis.server.pipeline import make_image_analysis_pipeline
from cv_analysis.table_inference import infer_lines


def test_table_inference_smoke():
    pl = make_image_analysis_pipeline(infer_lines)
    with open("test/test_data/article.pdf", "rb") as f:
        pdf_bytes = f.read()
    vlp_mock = {
        "data": [
            {
                "page_idx": 1,
                "boxes": [
                    {
                        "uuid": "marius-marius-gib-mir-meine-legionen-wieder",
                        "label": "table",
                        "box": {"x1": 100, "y1": 100, "x2": 200, "y2": 200},
                    }
                ],
            }
        ]
    }
    data = {"pdf": pdf_bytes, "vlp_output": vlp_mock}
    output = list(pl(data))
    if output:
        lines = output[0]["tableLines"]
        # assert len(lines) > 1
        # assert all(map(lambda item: sorted(item.keys()) == ["x1", "x2", "y1", "y2"], lines))
