"""storage/가 링크(정션)일 때 업로드 경로 기준이 어긋나지 않는지. 워크트리를 나눠 쓰면 `storage/`가 본 폴더로 가는 정션이다. 저장 엔진은 `Path.resolve()`로 링크를 따라가는데 프로젝트 루트가 링크 경로 그대로면 `chunk_path.relative_to(project_root)`가 ValueError로 터졌다(2026-08-30 실사고). """ import os import sys from pathlib import Path import pytest PROJECT_ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(PROJECT_ROOT)) def test_resolve_stored_project_path_follows_storage_link(tmp_path, monkeypatch): real_storage = tmp_path / "real" / "storage" (real_storage / "1" / "3" / "proj").mkdir(parents=True) link_storage = tmp_path / "work" / "storage" link_storage.parent.mkdir(parents=True) try: os.symlink(real_storage, link_storage, target_is_directory=True) except (OSError, NotImplementedError) as exc: # 권한 없으면 검사 불가 pytest.skip(f"심볼릭 링크를 만들 수 없음: {exc}") import common_util.common_util_storage as storage monkeypatch.setattr(storage, "STORAGE_BASE_DIR", str(link_storage)) resolved = Path(storage.resolve_stored_project_path("storage/1/3/proj")) # 저장 엔진이 쓰는 기준(resolve)과 같은 경로여야 한다 assert resolved == resolved.resolve() # 그래야 엔진이 만든 하위 경로를 프로젝트 루트 기준 상대경로로 뺄 수 있다 chunk = (resolved / "B03_FileInput" / "chunks_temp" / "s1" / "00000000.chunk").resolve() assert chunk.relative_to(resolved).as_posix().startswith("B03_FileInput/")