From 6606ef167ab166f389d9281ca307ef8abc08dac0 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Mon, 28 Sep 2026 21:35:24 +0900 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFfix(M02):=20=EC=93=B0=EB=8A=94=20?= =?UTF-8?q?=EC=96=91=EC=8B=9D(=EA=B5=AC=EC=A1=B0=EB=AC=BC=EC=A7=91?= =?UTF-8?q?=EA=B3=84=ED=91=9C=20=C2=B7=20B07=20=EB=8F=84=EA=B0=81=20=C2=B7?= =?UTF-8?q?=20=EB=B0=A9=EC=9C=84=ED=91=9C=20=C2=B7=20=ED=91=9C=EC=A7=80)?= =?UTF-8?q?=20=EC=A7=80=EC=9A=B0=EA=B8=B0=20=EB=A7=89=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 서버 delete 가 409 「쓰는 양식이라 못 지움」 · 이름은 B07 엔진 상수와 시험으로 맞춤 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011vX53nJGC8ucBRFJns2n7B --- M02_MasterTemplete/M02_MasterTemplete_Store.py | 9 +++++++++ resources/tester/test_m02_store.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/M02_MasterTemplete/M02_MasterTemplete_Store.py b/M02_MasterTemplete/M02_MasterTemplete_Store.py index c846c529..30ded48a 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Store.py +++ b/M02_MasterTemplete/M02_MasterTemplete_Store.py @@ -27,6 +27,13 @@ KINDS = layers.KINDS # 시험은 FOLDER 를 사본으로 바꿈 # (제목행 = 열 `머리` 네 층 · 없는 층 00) — 한 열의 세 번호는 같은 8자리 · # 한 번 준 번호는 파일에 남아 안 바뀜(PLAN 13장) STRUCTURE_TABLE = "구조물집계표" +# 프로그램이 이름으로 부르는 양식 — 지우면 그 기능이 죽음(B07 이름은 `B07_DesignDetail_Engine_*`) +IN_USE = { + ("table", STRUCTURE_TABLE): "구조물 도면 · 면적산출 · 재료산출 · 조합 장부가 씀", + ("drawing", "00_template_A1"): "B07 도면 도각", + ("drawing", "00_template_compass"): "B07 방위표", + ("drawing", "00_template_cover"): "B07 표지", +} # (종류, 문서 번호 칸, 머리 글자, 시트 이름) — 시트 이름이 None 이면 구조물 도면 PARTS = ( ("structure", "도번", "SD", None), @@ -138,6 +145,8 @@ def write(kind: str, name: str, version: str, doc: Any) -> dict[str, Any]: def delete(kind: str, name: str, version: str | None = None) -> None: path = _path(kind, name) + if (kind, name) in IN_USE: + raise StoreError(409, f"쓰는 양식이라 못 지움 「{name}」 — {IN_USE[(kind, name)]}") with _LOCK: if not path.is_file(): raise StoreError(404, f"없는 양식 「{name}」") diff --git a/resources/tester/test_m02_store.py b/resources/tester/test_m02_store.py index 33fa89a0..b4fb860a 100644 --- a/resources/tester/test_m02_store.py +++ b/resources/tester/test_m02_store.py @@ -86,6 +86,22 @@ def test_copy_is_independent_and_seeds_new_project(client, tmp_path, monkeypatch assert [r["이름"] for r in client.get("/api/m02/templates").json()] == ["원본"] +def test_in_use_templates_not_deleted(client): + """프로그램이 이름으로 부르는 양식은 못 지움 — 이름은 B07 엔진 상수와 같음.""" + from B07_DesignDetail import B07_DesignDetail_Engine_Cad_Cover as cover + from B07_DesignDetail import B07_DesignDetail_Engine_Template as tpl + + names = {tpl.A1_TEMPLATE, tpl.COMPASS_TEMPLATE, cover.COVER_TEMPLATE} + assert {n for k, n in store.IN_USE if k == "drawing"} == names + doc = {"format": 6, "entities": [{"type": "line"}]} + for kind, name in store.IN_USE: + body = doc if kind == "drawing" else {"열": []} + client.put(f"/api/m02/templates/{kind}/{name}", json={"판": "", "문서": body}) + got = client.delete(f"/api/m02/templates/{kind}/{name}") + assert got.status_code == 409 and "쓰는 양식" in got.json()["detail"] + assert client.get(f"/api/m02/templates/{kind}/{name}").status_code == 200 + + def test_empty_doc_rejected_and_file_untouched(client): good = {"format": 6, "entities": [{"type": "line"}]} made = client.put("/api/m02/templates/drawing/도", json={"판": "", "문서": good})