- 명세 항목 꼴 「글」(kind text · 길이 상한 TEXT_MAX 100 · 비우기 · 이름 표 · M02 이름 나무 꼴 「글」)
- 다 빈 선택 인스턴스도 첫 칸을 빈 글로 남겨 자리 지킴 — 잇기 · 집계 줄 · 다시 열기
- 기타 = 선택 컨테이너 「상세 내용」(비고 글 · etc_detail_{n}_note · 잇기 getcdetail{n}) · 종류 단위 잇기 줄 가림 규칙 그대로
- 집계 모음: 기타 건 이름(그룹) = 상세 종류 이름 · 비면 「기타」 · 컨테이너 건 = 이름 + n · 서버 컨테이너 표에 기타 짝
- 시험: test_52_14_etc_text · 헬퍼 etc · ui_checks 52-10 에 기타 컨테이너 단계 · 52-1 스크립트는 보이는 명세 폼을 잡음
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVPp2o6Mh2FZJr72yW3ofZ
107 lines
3.9 KiB
Python
107 lines
3.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""공용 틀 글 손 입력 · 기타 선택 컨테이너 · 기타 이름 = 집계 건 이름 — PLAN 52-14.
|
|
|
|
순수 규칙은 Node 헬퍼(`helper_52_structure_spec.cjs etc`)가 돌림 ·
|
|
화면은 ORCA `ui_checks/52-10_노면공_기타.js`(52-14 덧).
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
from M02_MasterTemplete import M02_Table_Fill as fill
|
|
from M02_MasterTemplete.M02_Table_Fill_Spec import SPEC_CONTAINERS, container_rows, etc_label
|
|
from resources.tester.test_structures_summary_snapshot import ( # noqa: F401 — world 고정물
|
|
MS,
|
|
RV,
|
|
_save,
|
|
world,
|
|
)
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
ROOT = os.path.dirname(os.path.dirname(HERE))
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def out():
|
|
proc = subprocess.run(
|
|
["node", os.path.join(HERE, "helper_52_structure_spec.cjs"), "etc"],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
return json.loads(proc.stdout)
|
|
|
|
|
|
def test_기타_선택_컨테이너_상세_내용(out):
|
|
assert out["same"] is True
|
|
assert out["containers"] == [["detail", "상세 내용", False, "etc_detail", "getcdetail"]]
|
|
assert out["items"] == [["note", "비고", "text"]]
|
|
assert out["links"] == ["getcdetail1", "getcdetail2"]
|
|
|
|
|
|
def test_글_저장_비우기_길이_상한(out):
|
|
assert out["state"] == {"detail": [{"note": "옛 비고"}, {"note": "둘째"}]} # n 차례대로 당김
|
|
edited = out["edited"]
|
|
assert edited["etc_detail_1_note"] == "새 비고" # 앞뒤 빈칸 뺌
|
|
assert edited["etc_detail_2_note"] == "" # 비운 인스턴스도 자리를 지킴(잇기 · 집계 줄)
|
|
assert out["longLen"] == out["max"] == 100
|
|
assert out["keys"] == {"keys": [], "prefixes": ["etc_detail_"]}
|
|
|
|
|
|
def test_이름_표에_글_항목(out):
|
|
assert out["names"] == {"detail": "상세 내용", "detail.note": "비고"}
|
|
|
|
|
|
def test_기타_이름이_집계_건_이름():
|
|
assert etc_label("etc", {"name": " 배수판 "}) == {"그룹": "배수판"}
|
|
assert etc_label("etc", {"name": ""}) == {"그룹": "기타"}
|
|
assert etc_label("etc", {}) == {"그룹": "기타"}
|
|
assert etc_label("pipe", {"name": "x"}) == {}
|
|
item = {
|
|
"type_id": "etc",
|
|
"options": {"name": "배수판", "etc_detail_1_note": "왼쪽", "etc_detail_2_note": ""},
|
|
"복사본": "st1",
|
|
"그룹": "배수판",
|
|
}
|
|
rows = container_rows(item, {"getcdetail1": RV, "getcdetail2": MS})
|
|
assert [r["그룹"] for r in rows] == ["배수판 1", "배수판 2"]
|
|
assert [r["복사본"] for r in rows] == ["st1__getcdetail1", "st1__getcdetail2"]
|
|
assert [r["summary_item"] for r in rows] == [RV, MS]
|
|
assert rows[0]["options"]["note"] == "왼쪽"
|
|
|
|
|
|
def test_집계_모음에_기타_이름과_컨테이너_건(world): # noqa: F811 — 고정물
|
|
root = world["root"]
|
|
etc = {
|
|
"structure_id": "etc1",
|
|
"type_id": "etc",
|
|
"placement": "point",
|
|
"chainage_m": 60.0,
|
|
"options": {"name": "배수판", "etc_detail_1_note": "왼쪽"},
|
|
"group_items": {"getcdetail1": RV},
|
|
}
|
|
blank = {**etc, "structure_id": "etc2", "chainage_m": 80.0, "options": {"name": ""}}
|
|
_save(root, [etc, blank], [])
|
|
items = {i["복사본"]: i for i in fill.collect_items(root)}
|
|
assert items["etc1"]["그룹"] == "배수판"
|
|
assert items["etc1__getcdetail1"]["그룹"] == "배수판 1"
|
|
assert items["etc1__getcdetail1"]["summary_item"] == RV
|
|
assert items["etc2"]["그룹"] == "기타"
|
|
|
|
|
|
def test_서버_컨테이너_표는_기타_명세와_짝():
|
|
with open(
|
|
os.path.join(ROOT, "A00_Common/design/design_structure_road.ts"), encoding="utf-8"
|
|
) as f:
|
|
text = f.read()
|
|
found = re.findall(
|
|
r'title: "([^"]+)",\s*required: false,\s*prefix: "(\w+)",\s*link: "(\w+)"', text
|
|
)
|
|
assert [(p, link, t) for t, p, link in found] == list(SPEC_CONTAINERS["etc"])
|