- M02 종류별 탭 [종류 더하기] = 본보기(구조물 정본 원본) 복사 — 키 자동 · 이름 「본보기 2」 · 옵션 · 표시 · 그룹 · 배치 · 규칙 · 종류 덧칸 · 반영 그대로 · 종류.{새}.본보기 · 관 지점 종류 · 복사본은 본보기 밖
- 구조물 표 = 본보기 처음값 이어받음(resolveCatalog · resolve_catalog 짝 · 줄 칸 base) · baseType/base_type · specFor(명세) · 덧단 · 길이 전후 풀기 · 옹벽 추가 단 콘크리트
- 검사(화면 = 서버 짝) — 본보기 = 원본 · 같은 군 · 자리꼴 · 정본 · 만든 뒤 고정 · 복사본은 본보기가 숨긴 칸 이어받음 · 서버 덧칸 본보기 받음
- 특수 동작 = 동작 이름 — 바로 안 놓기 · 포장 나누기 = 포장_물넘이_겹침 · 월류 높이 기다림 = 월류단면
- 정본 목록 = 표 — 파이썬 관 지점 종류 = catalog owner · B05 시설 서브폼 = 표 형상 · 안 쓰는 손 목록 걷음
- drawing_views — 스키마에서 빼고 읽을 때 버림 · M02 [저장] 때 빠짐(코드는 마스터 안 고침)
- 이관 = 지난 판 이름 대신 측점 계획 자리(planted)로 가름 · all_type_names 걷음
- 허용 거리 = common_util_structure_station.py 한 곳(SAME_STATION_M · EDGE_TOLERANCE_M · PIPE_MATCH_M) · TS 표는 station.ts 머리
- 시험: test_323_7_new_type(템플릿 · 일곱 갈래 · 그림 · 검사 짝 · 서버 읽기) · 322-0 유령 시험 = 자리 · 옛 도움 파일 동작 · 표 길 · 기대 글 고침
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
69 lines
3.2 KiB
Python
69 lines
3.2 KiB
Python
"""PLAN 322-0 ② → 323-7 — 「기타」 유령 길 막기: 종류 이름을 바꾼 뒤에도 옛 이름 측점을 안 되옮김.
|
|
|
|
정의 사본(임시 폴더 · 마스터 안 고침)에서 종류 이름을 바꿈 → 지금 관 · 구조물이 심는 자리(측점
|
|
계획)의 측점은 옛 이름 · 새 이름 모두 이관 0건(323-7 · 자리로 가름 · 지난 판 이름 되짚기 걷음).
|
|
옛 꼴 자유 글(기성막이 · 대피로 폭 · 임의 이름)은 심는 자리가 아니면 종전대로 옮김.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from B05_Profile import B05_Profile_Structures_Schema as schema
|
|
from B05_Profile.B05_Profile_Structures_Migration import migrate_irregular_stations
|
|
|
|
MASTER = Path(schema.DEFINITION_PATH)
|
|
RENAMED = {
|
|
"cross_drain_exposed": "노출수로",
|
|
"box_culvert": "박스암거",
|
|
"retaining_wall": "옹벽(신)",
|
|
}
|
|
|
|
|
|
@pytest.fixture()
|
|
def renamed(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> dict:
|
|
old = json.loads(MASTER.read_text(encoding="utf-8"))
|
|
history = tmp_path / schema.HISTORY_DIRNAME
|
|
history.mkdir()
|
|
shutil.copy(MASTER, history / f"판_{old['판']}.json")
|
|
new = {**old, "판": old["판"] + 1}
|
|
new["types"] = [{**t, "name": RENAMED.get(t["type_id"], t["name"])} for t in old["types"]]
|
|
path = tmp_path / "구조물정의.json"
|
|
path.write_text(json.dumps(new, ensure_ascii=False), encoding="utf-8")
|
|
monkeypatch.setattr(schema, "DEFINITION_PATH", str(path))
|
|
return old
|
|
|
|
|
|
def _moved(label: str, planted: tuple[float, ...] = ()) -> int:
|
|
plan = migrate_irregular_stations([{"chainage_m": 120.0, "structure": label}], planted)
|
|
return len(plan.structures) + len(plan.pipe_facilities)
|
|
|
|
|
|
def test_old_and_new_names_at_planted_spots_are_not_migrated(renamed: dict) -> None:
|
|
# 323-7 — 자리로 가름(지금 관 · 구조물이 심는 자리) · 이름을 바꿔도 자리는 그대로
|
|
assert schema.structure_type_map()["box_culvert"].name == "박스암거" # 사본을 읽음
|
|
for type_id, name in RENAMED.items():
|
|
old_name = next(t["name"] for t in renamed["types"] if t["type_id"] == type_id)
|
|
assert _moved(old_name, (120.0,)) == 0, old_name
|
|
assert _moved(name, (120.0,)) == 0, name
|
|
assert _moved(name) == 0, name # 지금 판 이름은 자리 없이도
|
|
|
|
|
|
def test_history_names_are_not_read(renamed: dict) -> None:
|
|
# 옛 이름 되짚기 걷음(323-7) — 자리를 못 받은 옛 이름 = 옛 자유 글처럼 「기타」
|
|
assert not hasattr(schema, "all_type_names")
|
|
assert _moved("노출형 횡단수로") == 1
|
|
|
|
|
|
def test_legacy_free_text_still_migrates(renamed: dict) -> None:
|
|
assert _moved("기성막이") == 1 # 옛 오기 → 기슭막이(관 지점)
|
|
plan = migrate_irregular_stations([{"chainage_m": 300.0, "structure": "대피로 2.0m"}])
|
|
assert [s.type_id for s in plan.structures] == ["refuge"]
|
|
plan = migrate_irregular_stations([{"chainage_m": 15.0, "structure": "돌망태 보강"}])
|
|
assert [(s.type_id, s.options["name"]) for s in plan.structures] == [("etc", "돌망태 보강")]
|
|
assert _moved("돌망태 보강", (120.004,)) == 0 # 심는 자리면 글이 무엇이든 안 옮김
|