- 기계.json 한 파일 → 폴더 기계/(EQ 키마다 파일 + _머리.json · 차례 = 키 차례) · 옮긴 빌더 build_기계폴더_826_2 (655 대 머리 · 줄 · 차례 대조 뒤 옛 파일 지움) - 읽기 도우미 master_machine_files — cm.load · Store_Cache · Store.read 가 옛 「기계.json」 한 표 꼴로 지어 줌(API · 화면 · 색인 그대로) · 쓰기 = 바뀐 대 파일만 - 기계.json 직접 열던 곳 도우미로: M02_San_Basis_Index · M02_Logic_Standard 지문 · build_용도 · master_keys.adopt · _틀 · _갱신절차 - 저장 몸 M01_MasterData_Store_Save — 전 = 기억 · 후 = 고친 파일만 얕은 사본 · 틀은 고친 줄만 · 조합 · 일위대가 문서는 로직 줄이 빠질 때만 · 재료 찾기 기억 이어받음 · 저장 뒤 쓴 파일만 기억에 갈아 끼움 - 마스터 사본 시험 22 개 = 기계 폴더도 복사 · 821_2 · 815_2 글 대조 = 대 파일 하나 대조(옛 한 파일 글 대조 낡음) - 새 시험 test_826_2 — 폴더 = 한 표 · 한 대 한 파일 · 새 · 지움 · 409 · 옛 길과 같은 오류 스무 견본 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.7 KiB
Python
72 lines
2.7 KiB
Python
"""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)
|
|
shutil.copytree(REAL / "기계", master / "기계") # 기계 = 폴더(826-2)
|
|
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": []}})
|