from __future__ import annotations

from tests.pipeline_setup.utils.rag_indexer import LocalRepoFileCollector


def test_local_repo_file_collector_skips_hidden_and_pycache_paths(tmp_path) -> None:
    (tmp_path / ".env").write_text("A=1", encoding="utf-8")
    (tmp_path / ".venv").mkdir()
    (tmp_path / ".venv" / "lib.py").write_text("x=1", encoding="utf-8")
    (tmp_path / "src").mkdir()
    (tmp_path / "src" / "__pycache__").mkdir()
    (tmp_path / "src" / "__pycache__" / "cache.py").write_text("x=2", encoding="utf-8")
    (tmp_path / "src" / ".hidden.py").write_text("x=3", encoding="utf-8")
    (tmp_path / "src" / "main.py").write_text("def main():\n    return 1\n", encoding="utf-8")

    files = LocalRepoFileCollector(tmp_path).collect()

    assert [item["path"] for item in files] == ["src/main.py"]
