"""CI-light tests for scripts/pdf_table_weave.py — fallback-only (plan AC6)."""

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))

import pdf_table_weave as ptw


def test_empty_specs_returns_zero_woven_zero_flagged():
    assert ptw.weave_tables(None, []) == {"woven": 0, "flagged": []}
    assert ptw.weave_tables(None, None) == {"woven": 0, "flagged": []}


def test_each_spec_flagged_incomplete_never_woven():
    specs = [{"page": 1, "bbox": [0, 0, 10, 10]}, {"page": 2, "bbox": [1, 1, 2, 2]}]
    result = ptw.weave_tables(None, specs)
    assert result["woven"] == 0
    assert len(result["flagged"]) == 2
    assert result["flagged"][0]["page"] == 1
    assert result["flagged"][0]["bbox"] == [0, 0, 10, 10]
    assert "incomplete" in result["flagged"][0]["reason"]
    assert result["flagged"][1]["page"] == 2
