reranker / tests /test_paths.py
Hemprasad Badgujar
Updated
0d4730e
Raw History Blame Contribute Delete
900 Bytes
"""Repo-anchored path resolution — must work regardless of the process working directory."""
from __future__ import annotations
from pathlib import Path
import pytest
from common.paths import DEFAULT_CANDIDATES, REPO_ROOT, resolve_candidates
def test_repo_root_points_at_the_repo() -> None:
assert (REPO_ROOT / "data").is_dir()
assert DEFAULT_CANDIDATES == REPO_ROOT / "data" / "candidates.jsonl"
def test_resolves_relative_path_from_a_foreign_cwd(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
"""Streamlit/HF launch from a non-repo cwd; a repo-relative path must still resolve."""
monkeypatch.chdir(tmp_path)
resolved = resolve_candidates("data/candidate_schema.json")
assert resolved.exists()
def test_missing_path_is_returned_unchanged(tmp_path: Path) -> None:
missing = tmp_path / "nope.jsonl"
assert resolve_candidates(missing) == missing