Files
Aislo/resources/tester/test_b05_protection_migration.py
T
eomsangdonandClaude Opus 5 0ef32b5279 chore(tester): 시험을 resources/tester/ 로 옮김 — 창끼리 건너가게
⚠ **뿌리** — `tmp/` 는 창 사이에 안 건너감(실측 확인: 상대 창이 놓은 `tmp/_sync_probe.txt`
가 시간을 두고 두 번 봐도 안 보임). 그래서 **정본(등록부 스키마)만 건너가고 그것을 읽는
시험은 안 건너가** 오늘 두 번, 같은 시험이 **연 창은 통과·받은 창은 실패**가 됐음.

- `tmp/tests/*` 를 `resources/tester/` 로 **복사**(127 파일). 내용은 **한 줄도 안 고침**
- `tmp/tests` 는 **남겨 둠** — 되돌릴 자리(사용자 지시)
- 실행: `./venv/Scripts/python.exe -m pytest resources/tester/ -q`
  옮기기 전과 **같은 수**: 617 통과 / 22 건너뜀 / 실패 0

⇒ 이제 시험·예외·까닭이 **정본과 함께** 움직임. 오늘 세운 「예외는 정본 스키마에」와 짝임.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 17:12:30 +09:00

79 lines
3.2 KiB
Python

"""보호공 개편(2026-08-17) 구 저장분 마이그레이션.
개편 전 유입·유출 바닥 보호는 `*_pitching`(있음/없음)과 `*_pitching_finish`(찰/메)
두 축이었다. 도수로·산비탈수로(B4)가 유출부에서 돌붙임 대신 쓰는 공종이라 세 값을
`*_protection` 한 축(돌붙임(찰)/돌붙임(메)/도수로)으로 합쳤고, "없음"은 삭제했다
(물이 흐르는 자리라 보호공은 필수 — 사용자 확정).
`parse_pipe_points`가 읽는 순간 새 키로 옮기므로 화면·수량 어느 쪽도 옛 키를 모른다.
"""
from common_util.common_util_drainage_pipes import parse_pipe_points
def _options(payload: dict) -> dict:
points = parse_pipe_points([{"chainage_m": 100.0, "options": payload}])
assert len(points) == 1
return points[0].options or {}
def test_legacy_pitching_with_finish_becomes_protection():
"""있음 + 찰/메 → 돌붙임(찰)/돌붙임(메). 면적은 새 키로 옮겨 탄다."""
options = _options(
{
"inlet_pitching": "있음",
"inlet_pitching_finish": "찰",
"inlet_pitching_area_m2": 9.0,
"outlet_pitching": "있음",
"outlet_pitching_finish": "메",
"outlet_pitching_area_m2": 25.0,
}
)
assert options["inlet_protection"] == "돌붙임(찰)"
assert options["outlet_protection"] == "돌붙임(메)"
assert options["inlet_protection_area_m2"] == 9.0
assert options["outlet_protection_area_m2"] == 25.0
def test_legacy_keys_are_removed():
"""옛 키가 남으면 화면·수량이 두 벌을 보게 된다."""
options = _options(
{"inlet_pitching": "있음", "inlet_pitching_finish": "찰", "inlet_pitching_area_m2": 9.0}
)
for gone in ("inlet_pitching", "inlet_pitching_finish", "inlet_pitching_area_m2"):
assert gone not in options, gone
def test_legacy_none_is_promoted_to_part_default():
"""구 "없음"은 선택지가 사라졌으므로 부위 기본값(유입 찰·유출 메)으로 올린다."""
options = _options({"inlet_pitching": "없음", "outlet_pitching": "없음"})
assert options["inlet_protection"] == "돌붙임(찰)"
assert options["outlet_protection"] == "돌붙임(메)"
def test_legacy_without_finish_falls_back_to_part_default():
"""표면처리가 빠진 구 저장분도 부위 기본값으로 채운다."""
options = _options({"outlet_pitching": "있음"})
assert options["outlet_protection"] == "돌붙임(메)"
def test_new_keys_win_over_legacy():
"""이미 새 키가 있으면 구 키가 덮어쓰지 않는다(재저장분 보호)."""
options = _options(
{
"inlet_protection": "도수로",
"inlet_protection_width_m": 1.0,
"inlet_pitching": "있음",
"inlet_pitching_finish": "찰",
}
)
assert options["inlet_protection"] == "도수로"
assert options["inlet_protection_width_m"] == 1.0
assert "inlet_pitching" not in options
def test_untouched_options_pass_through():
"""보호공과 무관한 옵션은 그대로 둔다."""
options = _options({"pipe_kind": "파형강관", "pipe_diameter_mm": 1000})
assert options == {"pipe_kind": "파형강관", "pipe_diameter_mm": 1000}