Files
Aislo/resources/tester/test_52_structure_spec_box.py
T
eomsangdonandClaude Opus 5.5 40126051dc refactor(859-5 ③④): 구조물 정의 자료 master_template → master_data/구조물정의
- 구조물정의.json → resources/master_data/구조물정의/구조물정의.json(git mv · 내용 그대로)
- 구조물정의_이력/판_1 ~ 22 → resources/master_data/구조물정의/이력/(git mv · 내용 그대로)
- 읽는 자리 = B05 Structures_Schema DEFINITION_PATH · HISTORY_DIRNAME · M01_SO_Definition HISTORY
- M01 요소 로더 · check_master 는 첫 층 *.json 만 읽음 — 새 폴더는 요소로 안 읽힘(수식문서/ 와 같은 대접)
- 시험 · 도우미 · ui_checks 경로 글 고침(파일 이름 그대로)
- resources/master_template 에 구조물 정의 자료 남지 않음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 22:09:35 +09:00

113 lines
4.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""횡단배수 › 박스암거(표 02 고친 판) 명세 — PLAN 52-2.
순수 규칙은 Node 헬퍼(`helper_52_structure_spec_box.cjs`)가 돌림 · 화면은 ORCA `ui_checks/52-2_박스암거_컨테이너.js`.
"""
import json
import os
import subprocess
import pytest
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(os.path.dirname(HERE))
def _node(*args):
proc = subprocess.run(
["node", os.path.join(HERE, "helper_52_structure_spec_box.cjs"), *args],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
@pytest.fixture(scope="module")
def out():
return _node()
def test_컨테이너_셋_모두_필수(out):
assert out["containers"] == [
["body", "본체", True],
["inlet", "유입 구조", True],
["outlet", "유출 구조", True],
["soil_add", "흙막이", False],
["chute_add", "도수로/돌붙임", False],
]
assert out["links"] == ["gboxbody", "gboxin", "gboxout", "gsoiladd1", "gchuteadd1"]
def test_선택지_표_02_그대로(out):
assert out["sizes"] == ["2.0×2.0", "3.0×3.0", "사용자 입력"]
assert out["structures"] == ["없음", "날개벽", "흙막이"]
def test_사용자_입력일_때만_가로_세로_칸(out):
assert out["customHidden"] is None
assert out["customShown"] == {"key": "body_width_m"}
def test_옛_값_읽기_규격_밖은_사용자_입력_있음은_날개벽(out):
st = out["old"]["state"]
assert st["body"][0] == {"size": "사용자 입력", "width": "3", "height": "2.5"}
assert st["inlet"][0]["structure"] == "날개벽"
back = out["old"]["out"]
assert back == {"body_width_m": 3, "body_height_m": 2.5, "wing_in": "날개벽"}
# 옛 날개벽 치수는 폼이 안 적음(병합이 이어 붙임 = 지난 정의 값)
assert "wing_in_length_m" not in back
assert "wing_in_length_m" in out["retired"]
def test_규격은_폭_높이_수로_저장_규격_칸은_저장_안_함(out):
assert out["preset"]["state"]["body"][0]["size"] == "2.0×2.0"
assert out["preset"]["out"] == {"body_width_m": 2, "body_height_m": 2, "wing_out": "없음"}
to = out["toPreset"]["out"]
assert to["body_width_m"] == 3 and to["body_height_m"] == 3
assert to["wing_out"] == "흙막이"
assert out["toCustom"]["out"] == {"body_width_m": 2.4, "body_height_m": 1.8}
assert "size" not in json.dumps(out["keys"])
def test_빈_값은_빈_채로(out):
assert out["blank"]["out"] == {}
assert out["blank"]["state"]["body"][0]["size"] == ""
def test_사용자_입력_빈_칸은_다시_열어도_사용자_입력(out):
# 52-19 — 가로만 비움: 세로 손 값이 남아 사용자 입력 + 빈 가로
assert out["oneBlank"]["state"]["body"][0] == {
"size": "사용자 입력",
"width": "",
"height": "2.5",
}
assert out["oneBlank"]["out"] == {"body_height_m": 2.5}
# 둘 다 비움: 표시 키만 적고 다시 열면 사용자 입력 + 빈 칸 둘
assert out["bothBlank"]["out"] == {"body_custom": "사용자 입력"}
assert out["bothBlankAgain"]["state"]["body"][0] == {
"size": "사용자 입력",
"width": "",
"height": "",
}
assert out["bothBlankAgain"]["out"] == {"body_custom": "사용자 입력"}
def test_정의_파일에_이름_표_그룹_선택지가_올라_있음():
names = _node("names")
with open(
os.path.join(ROOT, "resources", "master_data", "구조물정의", "구조물정의.json"),
encoding="utf-8",
) as f:
doc = json.load(f)
# 그림 전용 길이 칸(294-4)은 마스터 정의 이름 표에 안 올림(마스터 손대지 않음) — 대조 밖
assert set(names) - {"chute_add.length_m"} == set(doc["종류"]["box_culvert"]["이름"])
assert [g["id"] for g in doc["그룹"]["box_culvert"]] == ["gboxbody", "gboxin", "gboxout"]
box = next(t for t in doc["types"] if t["type_id"] == "box_culvert")
wing = {o["key"]: o for o in box["options"]}
for key in ("wing_in", "wing_out"):
assert wing[key]["choices"] == ["없음", "날개벽", "흙막이"]