"""794-1b — M01 흐름도 걷음 뒤 지킴(마스터 사본 폴더 · 정본 안 바뀜). 못박는 것 - 흐름 길(`/api/m01/logic/flow` · `/api/m02/df/values` …) 없음 · 남긴 바닥 `GET /api/m02/df/standards` 는 그대로 - [신규 로직] = 흐름 없는 빈 시트 줄 → `/save` 가 자체 파일 GX 새 키 · 구분 자체 · 셈은 옛 셈 - 줄에 「흐름」 이 남아 있으면 엔진이 까닭 글로 막음(조용히 틀린 값 안 냄) """ from __future__ import annotations import shutil from pathlib import Path import pytest from fastapi import FastAPI from fastapi.testclient import TestClient from M01_MasterData import M01_MasterData_Router as m01_router from M01_MasterData import M01_MasterData_Store as store from M02_MasterTemplete.DataFlow import M02_DF_Router as df REAL = store.FOLDER OWN = "로직_자체.json" @pytest.fixture def client(tmp_path: Path, monkeypatch) -> TestClient: master = tmp_path / "master" master.mkdir() for path in REAL.glob("*.json"): shutil.copy(path, master / path.name) monkeypatch.setattr(store, "FOLDER", master) app = FastAPI() app.include_router(m01_router.router) app.include_router(df.router) return TestClient(app) def test_흐름_길은_없고_표준_표는_남음(client: TestClient) -> None: assert client.get("/api/m01/logic/flow", params={"key": "GF000219"}).status_code == 404 assert client.post("/api/m02/df/values", json={"items": []}).status_code == 404 got = client.get("/api/m02/df/standards").json() assert got["unit"]["줄"] and got["money"]["줄"] def test_신규_로직은_시트_줄로_자체_GX(client: TestClient) -> None: version = store.read(OWN)[1] if (store.FOLDER / OWN).is_file() else "" row = { "키": "", "이름": "sub3임시 새 로직", "결과단위": "원/㎡", "출처": "자체", "입력": [], "중간": [], "호표": [], "끝수": None, } part = {"file": OWN, "version": version, "changes": [{"op": "add", "row": row}]} res = client.post("/api/m01/save", json={"files": [part]}) assert res.status_code == 200, res.text added = res.json()["added"] assert len(added) == 1 and added[0]["key"].startswith("GX") saved = client.get("/api/m01/logic", params={"key": added[0]["key"]}).json()["logic"] assert saved["구분"] == "자체" and saved["이름"] == "sub3임시 새 로직" and "흐름" not in saved def test_흐름이_남은_줄은_까닭으로_막음() -> None: mf = store.cm.mf with pytest.raises(mf.FormulaError, match="흐름도 로직은 걷음"): mf.inputs_of({"흐름": {"boxes": [], "links": []}})