File size: 900 Bytes
0d4730e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""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