from pathlib import Path

from scripts.quant.manifest import load_manifest


def test_load_manifest_skips_blanks_and_comments(tmp_path):
    repo = tmp_path / "repo"
    repo.mkdir()
    (repo / "a.png").write_bytes(b"x")
    (repo / "b.jpg").write_bytes(b"y")
    manifest = tmp_path / "manifest.txt"
    manifest.write_text("# header\n\na.png\nb.jpg\n", encoding="utf-8")

    result = load_manifest(manifest, repo)

    assert result == [repo / "a.png", repo / "b.jpg"]


def test_load_manifest_raises_on_missing_image(tmp_path):
    repo = tmp_path / "repo"
    repo.mkdir()
    manifest = tmp_path / "manifest.txt"
    manifest.write_text("missing.png\n", encoding="utf-8")

    try:
        load_manifest(manifest, repo)
        assert False, "expected FileNotFoundError"
    except FileNotFoundError as exc:
        assert "missing.png" in str(exc)
