"""일위대가 사전조합 구분 · 상세구분 새 분류(PLAN 134-5) — 구조물군 A~G › 그 군 종류 + 「공통」. - 원천 = 마스터 `구조물정의.json`(구조물군 · types) — 군마다 첫 상세구분 「공통」 · 꺼진 종류도 · 「호환(기타)」 뺌 - 옛 품셈 분류(건설품셈 공통 · 산림품셈) = 읽을 때 빈 값(미분류) · 파일 안 고침 · 새 분류 값 · 지금 값은 그대로 - 새 문서 = 빈 값(미분류) · 상세 드롭다운 원천 = 구조물 정의(로직 구분 목록 아님) """ import json import os import subprocess from pathlib import Path from M02_MasterTemplete import M02_Labor_Ref as refs HERE = os.path.dirname(os.path.abspath(__file__)) ROOT = Path(HERE).parents[1] M02 = ROOT / "M02_MasterTemplete" def test_분류는_구조물군_종류_공통(): defn = json.loads((ROOT / "resources/master_template/구조물정의.json").read_text("utf-8")) proc = subprocess.run( ["node", os.path.join(HERE, "helper_m02_precombo_scope.cjs")], input=json.dumps({"rows": [], "def": defn}, ensure_ascii=False), capture_output=True, text=True, encoding="utf-8", check=True, ) classes = json.loads(proc.stdout)["classes"] groups = {k: v for k, v in defn["구조물군"].items() if k in "ABCDEFG"} assert [c["name"] for c in classes] == list( groups.values() ) # A 횡단배수 … G 노면공 · 기타 없음 c = next(c for c in classes if c["name"] == groups["C"]) assert c["details"] == [ "공통", "옹벽", "돌쌓기(찰)", "돌쌓기(메)", "흙막이", "큰돌쌓기", "소단", ] b = next(c for c in classes if c["name"] == groups["B"]) assert "측구(옆도랑)" in b["details"] # 꺼진 종류도 넣음 assert all( c["details"][0] == "공통" and len(set(c["details"])) == len(c["details"]) for c in classes ) def test_옛_품셈_분류는_미분류_새_값은_그대로(): old = {"이름": "가", "구분": "건설품셈 공통", "상세구분": "07장 돌공사", "담은로직": []} got = refs.filled("precombo", old) assert (got["구분"], got["상세구분"]) == ("", "") and old["구분"] == "건설품셈 공통" assert refs.filled("precombo", {**old, "구분": "산림품셈", "상세구분": "03장"})["구분"] == "" now = {**old, "구분": "C 사면안정", "상세구분": "옹벽"} assert refs.filled("precombo", now) is now gone = {**old, "구분": "Z 없어진 군", "상세구분": "x"} # 지금 값은 선택지로(화면 몫) assert refs.filled("precombo", gone) is gone assert refs.filled("precombo", {"담은로직": []})["구분"] == "" # 칸 없는 옛 문서 def test_화면_원천은_구조물_정의_새_문서는_미분류(): detail = (M02 / "M02_MasterTemplete_Labor_Detail.ts").read_text("utf-8") assert "subs = precomboClasses(def);" in detail and "fetchLibLogicSubs" not in detail assert '[...new Set([now ?? "", ...names])]' in detail # 지금 값도 선택지 그대로 lib = (M02 / "M02_MasterTemplete_Library_List.ts").read_text("utf-8") assert '구분: "", 상세구분: ""' in lib and "fetchLibLogicSubs" not in lib