"""새 자료로 갈아 끼울 때 「지우고 진행할까?」를 먼저 묻는지. 왜 있나(2026-09-08) — 업로드 하나가 그 프로젝트의 설계 산출물·초기값 스냅숏을 **되돌릴 수 없게** 지운다. 창 넷이 한 프로젝트를 볼 수 있어 말없이 지우면 남의 작업이 사라진다. 사람이 올리는 갈래만 묻고, 자동 절차는 안 막는다. """ from __future__ import annotations from pathlib import Path import pytest from B03_FileInput.B03_FileInput_Router_Helpers import ( OutputsWouldBeDiscarded, _confirm_replace_response, describe_existing_outputs, ) def test_산출물이_없으면_묻지_않는다(tmp_path: Path) -> None: (tmp_path / "B03_FileInput" / "input").mkdir(parents=True) (tmp_path / "B03_FileInput" / "input" / "a.las").write_text("x", encoding="utf-8") assert describe_existing_outputs(tmp_path) == [] def test_설계_산출물과_초기값을_사람_말로_알린다(tmp_path: Path) -> None: (tmp_path / "B05_Profile" / "route").mkdir(parents=True) (tmp_path / "B05_Profile" / "route" / "route.json").write_text("{}", encoding="utf-8") (tmp_path / "B06_Section").mkdir() (tmp_path / "B06_Section" / "cross.json").write_text("{}", encoding="utf-8") (tmp_path / "initial_snapshot").mkdir() targets = describe_existing_outputs(tmp_path) assert "노선·종단 설계" in targets assert "횡단 설계" in targets assert any("초기값" in item for item in targets) # B03 입력은 「지워지는 것」이 아니다 — 새 자료가 얹히는 자리다. assert all("입력" not in item for item in targets) def test_빈_폴더만_있으면_지울_것이_없다(tmp_path: Path) -> None: (tmp_path / "B05_Profile" / "route").mkdir(parents=True) (tmp_path / "B08_Quantity").mkdir() assert describe_existing_outputs(tmp_path) == [] def test_확인_응답은_409_이고_무엇이_지워지는지_담는다() -> None: response = _confirm_replace_response(OutputsWouldBeDiscarded(["횡단 설계", "수량 산출"])) body = response.body.decode("utf-8") assert response.status_code == 409 assert "replace_outputs" in body assert "\\ub418\\ub3cc\\ub9b4" in body or "되돌릴" in body # 문구에 「되돌릴 수 없」 assert "\\ud6a1\\ub2e8" in body or "횡단" in body def test_자동_절차는_기본으로_안_묻는다() -> None: """`confirm_replace` 기본이 True 여야 체인·스크립트가 물음에 안 걸린다.""" import inspect from B03_FileInput.B03_FileInput_Router_Helpers import _complete_file_input_if_ready default = inspect.signature(_complete_file_input_if_ready).parameters["confirm_replace"].default assert default is True @pytest.mark.parametrize("stage", ["B04_PreProcess", "B07_DesignDetail", "B09_Estimation"]) def test_모든_산출물_단계를_본다(tmp_path: Path, stage: str) -> None: (tmp_path / stage).mkdir(parents=True) (tmp_path / stage / "out.json").write_text("{}", encoding="utf-8") assert describe_existing_outputs(tmp_path), stage