"""PLAN 54-26 — 사용자 구조물 표 09 사면안정 › 흙막이 · 옹벽 · 소단. · 컨테이너 = 흙막이 「흙막이」 · 옹벽 「옹벽」 · 소단 「상세 내용」 — 칸은 표대로만 · 표 밖 옛 칸은 숨김(값 · 기본값 그대로) · 흙막이 형태 = 배관 흙막이 6 · 옹벽 형태 = 콘크리트 하나(새 칸 `wall_form` · 옛 형식 `form` 값은 그대로 통과) """ import json from pathlib import Path from B05_Profile.B05_Profile_Structures_Repository import _validate_types from B05_Profile.B05_Profile_Structures_Schema import ( DEFINITION_PATH, StructureInstance, load_structure_types, ) from M02_MasterTemplete.StructOptions import M02_SO_Definition from M02_MasterTemplete.StructOptions.M02_SO_Groups import groups_of from M02_MasterTemplete.StructOptions.M02_SO_Options import hidden_keys TABLE = { "soil_guard": ( "gsoilgdetail", "흙막이", ["form", "length_m", "height_m", "before_m", "after_m"], ), "retaining_wall": ( "gretaindetail", "옹벽", ["wall_form", "length_m", "height_m", "before_m", "after_m"], ), "berm": ("gbermdetail", "상세 내용", ["width_m", "height_m"]), } SOIL_FORMS = ["돌쌓기(찰)", "돌쌓기(메)", "콘크리트", "돌망태", "통나무·목재틀", "바자"] def _types(): return {t.type_id: t for t in load_structure_types()} def test_컨테이너_하나_칸은_표대로_차례대로(): groups = groups_of() types = _types() hidden = hidden_keys() for type_id, (gid, name, keys) in TABLE.items(): assert groups[type_id] == [{"id": gid, "name": name, "options": keys}] options = [o.key for o in types[type_id].options] assert options[: len(keys)] == keys # 칸 차례 = 표 차례 assert hidden[type_id] == set(options) - set(keys) # 표 밖 = 숨김(값은 남음) def test_형태_선택지(): types = _types() soil = {o.key: o for o in types["soil_guard"].options} pipe = {o.key: o for o in types["pipe"].options} assert soil["form"].choices == SOIL_FORMS == pipe["outlet_revet_form"].choices assert soil["form"].phase == "b05" # B05 = B06 wall = {o.key: o for o in types["retaining_wall"].options} assert wall["wall_form"].choices == ["콘크리트"] assert "반중력식" in wall["form"].choices # 옛 형식 값 그대로 통과 doc = json.loads(Path(DEFINITION_PATH).read_text("utf-8")) assert doc["종류"]["soil_guard"]["이름"]["form=통나무·목재틀"] == "통나무/목재틀" def test_옛_값_저장_막지_않음(): def item(type_id, **options): return StructureInstance( type_id=type_id, placement="interval", chainage_m=20, start_m=20, end_m=30, options={"length_m": 10, "before_m": 0, "after_m": 10, **options}, ) _validate_types( [ item("soil_guard", height_m=2), # 형태 없는 옛 흙막이 item("retaining_wall", form="반중력식", height_m=2), item("berm", width_m=0.5, interval_m=3, height_m=5), ] ) def test_정의_검사_통과_판_이력(): doc = json.loads(Path(DEFINITION_PATH).read_text("utf-8")) assert M02_SO_Definition.check(doc) == [] assert M02_SO_Definition.history_path(doc["판"] - 1).is_file()