# tests/test_pack_binary_exclude.py
from __future__ import annotations

from pathlib import Path

import oceansguard.cli as cli
from tests.conftest import _touch, _write, read_text, write_aiguard_yml


def test_pack_excludes_binary_like_files(tmp_path: Path, ux, patch_subprocess_for_pack):
    repo = tmp_path / "repo"
    repo.mkdir()

    _write(repo / "backend" / "app" / "main.py", "print('x')\n")
    _write(repo / "contracts" / "openapi.json", '{"openapi":"3.0.0","info":{"title":"t","version":"1"}}\n')
    _write(repo / "README.md", "# r\n")

    # 除外対象（png/pdf/zip）
    _touch(repo / "docs" / "image.png", size_bytes=100)
    _touch(repo / "docs" / "spec.pdf", size_bytes=100)
    _touch(repo / "archive.zip", size_bytes=100)

    write_aiguard_yml(repo, include_frontend_in_roots=False, max_files=200, max_kb_each=64)

    cli.cmd_pack(ux, repo, strict=False)

    txt = read_text(repo / "ai_context_pack.md")
    assert "image.png" not in txt
    assert "spec.pdf" not in txt
    assert "archive.zip" not in txt
    assert "backend/app/main.py" in txt
