Files
Aislo/resources/tester/test_129_menu_equals_panel.py
T
eomsangdonandClaude Opus 5.5 e4b9b3e5a3 refactor(859-5 ②): 구조물 정의 코드 M02 StructOptions → M01_MasterData/StructOptions
- 파일 23 개 git mv · 이름 M02_SO_* → M01_SO_* · 내용 · 동작 · 화면 글 그대로
- 서버 주소 /api/m02 → /api/m01(이름만 · 10 길 · 수 469 그대로) · main.py 등록 이름 m01_so_*
- 화면 부름 = common_util_m02_call 의 call 에 base 인자(기본 /m02 · 구조물 정의만 /m01)
- import 고침 = B05 · B07 · B08 · M01 · M02 · main · 시험 · 도우미
- 소스 글자만 보던 시험 셋 지움(구조물 정의 옮김에 걸림 · 결과를 안 봄):
  test_m02_structure_options 좌측 줄 · test_m02_structure_option_groups 좌측 정의 줄 · test_136_3 M02 미리보기 단추 CSS
- test_553_5 부품 훑기 폴더 = 옮긴 자리

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

90 lines
3.5 KiB
Python

# -*- coding: utf-8 -*-
"""129-1 종단 우클릭 구조물군 · 종류 목록 = 좌측 패널 「구조물 배치」 군 · 종류 드롭다운.
못박는 것
- 실제 레지스트리(`with_visible`) + 구조물 정의(`구조물정의.json`)로 화면과 같은 종류 목록을 세워,
패널 드롭다운에 보이는 군(차례 · 이름) · 종류(차례 · 이름 · id) = 우클릭 메뉴 — B05(켜진 종류) · B06(전부).
- 메뉴 길 넷(B05 종단 · 배수유역도 · 3D · B06 종단 = 한 profile)이 모두 패널 `pickGroups()` 를 봄.
Node 헬퍼 `helper_129_menu_equals_panel.cjs` 가 패널 · 메뉴 목록을 뽑음. 화면은 사용자 확인.
"""
import json
import os
import subprocess
import pytest
from M01_MasterData.StructOptions import M01_SO_Definition as definition
from M01_MasterData.StructOptions.M01_SO_Options import with_visible
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
def _read(*parts: str) -> str:
with open(os.path.join(ROOT, *parts), encoding="utf-8") as f:
return f.read()
@pytest.fixture(scope="module")
def out(tmp_path_factory):
folder = tmp_path_factory.mktemp("t129")
types_path = folder / "types.json"
definition_path = folder / "definition.json"
types_path.write_text(json.dumps(with_visible().model_dump()["types"]), "utf-8")
definition_path.write_text(json.dumps(definition.read()), "utf-8")
proc = subprocess.run(
[
"node",
os.path.join(HERE, "helper_129_menu_equals_panel.cjs"),
str(types_path),
str(definition_path),
],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
)
assert proc.returncode == 0, proc.stderr
return json.loads(proc.stdout)
@pytest.mark.parametrize("page", ["b05", "b06"])
def test_우클릭_목록은_패널_드롭다운과_같음(out, page):
panel, menu = out[page]["panel"], out[page]["menu"]
assert panel, "패널 목록이 비면 대조가 안 됨"
assert menu == panel # 군 차례 · 이름 · 종류 차례 · 이름 · 누르면 넘어가는 id
def test_B05_는_꺼진_종류를_안_보임(out):
shown = {type_id for group in out["b05"]["menu"] for _, type_id in group["types"]}
off = {t["type_id"] for t in with_visible().model_dump()["types"] if not t["enabled"]}
assert off and not shown & off
def test_옛_대피_종류는_어느_쪽도_안_보임(out):
for page in ("b05", "b06"):
shown = {type_id for group in out[page]["menu"] for _, type_id in group["types"]}
assert not shown & {"refuge", "work_yard", "turnaround"}
def test_메뉴_길_넷이_패널_목록을_봄():
assert "pickGroups: () => pickGroups(types, canPick)" in _read(
"B05_Profile", "B05_Profile_UI_Structures_Panel.ts"
)
# B05 · B06 한 profile — 종단그래프 · 배수유역도 우클릭은 공용 콜백 하나
assert "structureGroups: () => sharedStructures(shared).pickGroups()" in _read(
"A00_Common", "design", "design_shared.ts"
)
assert "structureGroups: callbacks?.structureGroups," in _read(
"B05_Profile", "B05_Profile_UI_Profile_Render.ts"
)
assert "structureGroupMenuItems(callbacks?.structureGroups?.() ?? []" in _read(
"A00_Common", "design", "design_profile.ts"
)
# 3D
assert "structureGroups: () => deps.panel().structures.pickGroups()" in _read(
"B05_Profile", "B05_Profile_UI_Page_Structures.ts"
)