Files
Aislo/resources/tester/test_52_6_cross_underdrain.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

87 lines
3.3 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 -*-
"""52-6 횡단배수 › 맹암거(표 06 · 새 종류) — 정의 · 컨테이너 · 서버 저장 왕복.
새 키 `cross_underdrain`(횡단배수 · 점형) — 종단배수 맹암거(`underdrain`)와 따로.
컨테이너 = 정의 그룹 「맹암거」(필수 · 늘 한 벌) — 암거 높이(m) · 암거 경사(%) 손 입력(비워 둘 수 있음) ·
그룹 잇기(`group_items`)로 구조물 조합 항목. 저장은 임시 storage 에서만.
"""
import pytest
from B05_Profile.B05_Profile_Structures_Schema import (
StructureInstance,
is_station_planting_type,
load_definition,
structure_type_map,
)
KEY = "cross_underdrain"
GROUP = "gcrossud"
def test_새_종류는_횡단배수_점형_종단배수_맹암거와_따로():
types = structure_type_map()
new, old = types[KEY], types["underdrain"]
assert (new.group, new.placement, new.name, new.enabled) == ("A", "point", "맹암거", True)
assert (old.group, old.placement) == ("B", "interval")
assert new.style["abbr"] != old.style["abbr"] and new.style["color"] != old.style["color"]
assert is_station_planting_type(new) # 횡단배수 = 그 측점에 횡단도
def test_컨테이너_맹암거_높이_경사_손_입력():
opts = {o.key: o for o in structure_type_map()[KEY].options}
assert list(opts) == ["culvert_height_m", "culvert_slope_pct"]
for key, label, unit in (
("culvert_height_m", "암거 높이", "m"),
("culvert_slope_pct", "암거 경사", "%"),
):
o = opts[key]
# 기본값 = 마스터 사용자 편집 몫 — 실제 값에 기대지 않음
assert (o.label, o.input, o.unit, o.required) == (label, "number", unit, False)
assert o.empty_means # 손 입력 · 기본값 근거 없음 — 비워 둘 수 있음(B05 단계 필수 금지)
groups = load_definition()["그룹"][KEY]
assert groups == [
{"id": GROUP, "이름": "맹암거", "옵션": list(opts), "형상": {}},
]
def test_정의_검사_통과():
from M01_MasterData.StructOptions import M01_SO_Definition as definition
assert definition.check(load_definition()) == []
def _item(**options):
return StructureInstance(
type_id=KEY,
placement="point",
chainage_m=63.5,
options=options,
group_items={
GROUP: {"layer": "system", "owner": None, "key": "SS000001", "name": "맹암거"}
},
)
def test_저장_다시_읽기_그대로(tmp_path):
from B05_Profile.B05_Profile_Structures_Repository import load_structures, save_structures
item = _item(culvert_height_m=0.6, culvert_slope_pct=2.5)
save_structures(str(tmp_path), [item], base_revision=0)
_, loaded = load_structures(str(tmp_path))
assert [(s.type_id, s.chainage_m, s.options) for s in loaded] == [
(KEY, 63.5, {"culvert_height_m": 0.6, "culvert_slope_pct": 2.5})
]
assert loaded[0].group_items == item.group_items
@pytest.mark.parametrize(
"options",
[{"culvert_height_m": -1}, {"culvert_slope_pct": -0.5}],
)
def test_음수는_서버가_막음(tmp_path, options):
from B05_Profile.B05_Profile_Structures_Repository import save_structures
with pytest.raises(ValueError):
save_structures(str(tmp_path), [_item(**options)], base_revision=0)