Files
Aislo/resources/tester/test_m01_logic_flow_folder.py
T

39 lines
1.1 KiB
Python

"""흐름도 적용(PLAN 36-4 · 정함 13) — 마스터 사본 폴더 길 시험.
· 환경 변수 AISLO_MASTER_DIR 가 있으면 M01 저장소 마스터 폴더 = 그 폴더 · 없으면 정본
"""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
PROBE = "from M01_MasterData import M01_MasterData_Store as s; print(s.FOLDER)"
def _folder(env_dir: str | None) -> Path:
env = {k: v for k, v in os.environ.items() if k != "AISLO_MASTER_DIR"}
if env_dir:
env["AISLO_MASTER_DIR"] = env_dir
got = subprocess.run(
[sys.executable, "-c", PROBE],
cwd=ROOT,
env=env,
capture_output=True,
text=True,
timeout=120,
)
assert got.returncode == 0, got.stderr
return Path(got.stdout.strip().splitlines()[-1])
def test_사본_폴더_변수가_있으면_그_폴더(tmp_path: Path) -> None:
assert _folder(str(tmp_path)) == tmp_path.resolve()
def test_변수가_없으면_정본() -> None:
assert _folder(None) == (ROOT / "resources" / "master_data").resolve()