feat(B05): 숨긴 옵션은 필수 아님 — 저장 검증이 M02 옵션 보이기 표를 봄 · 시험 한 건
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6KXAabDTenEU7hrDQmCKY
This commit is contained in:
@@ -27,6 +27,10 @@ URL = "/api/m02/structure-options"
|
||||
TYPES = "/api/projects/structure-types"
|
||||
|
||||
|
||||
def structure_type(type_id):
|
||||
return next(t for t in load_structure_types() if t.type_id == type_id)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(tmp_path: Path, monkeypatch) -> TestClient:
|
||||
monkeypatch.setattr(store, "FOLDER", tmp_path)
|
||||
@@ -127,3 +131,38 @@ def test_좌측_줄은_구조물_집계_양식_아래_한_줄_같은_한_곳에
|
||||
)
|
||||
ui = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Options.ts").read_text("utf-8")
|
||||
assert 'o.phase === "detail"' in ui # B06 전용 표시
|
||||
|
||||
|
||||
def test_숨긴_옵션은_필수_아님_저장이_안_막힘(client, tmp_path, monkeypatch) -> None:
|
||||
"""B05 필수(기본값 없음) 옵션 — 보이면 막고 숨기면 저장됨(다른 필수는 그대로)."""
|
||||
from B05_Profile import B05_Profile_Structures_Repository as repo
|
||||
from B05_Profile.B05_Profile_Structures_Schema import (
|
||||
StructureInstance,
|
||||
StructureOptionField,
|
||||
StructureType,
|
||||
)
|
||||
|
||||
def must(key):
|
||||
return StructureOptionField(key=key, label=key, input="number", required=True, phase="b05")
|
||||
|
||||
fake = StructureType(
|
||||
type_id="fake_hide",
|
||||
group="Z",
|
||||
name="가짜",
|
||||
placement="point",
|
||||
options=[must("a"), must("b")],
|
||||
)
|
||||
real = repo.structure_type_map()
|
||||
monkeypatch.setattr(repo, "structure_type_map", lambda: {**real, "fake_hide": fake})
|
||||
item = lambda opts: StructureInstance.model_validate( # noqa: E731
|
||||
{"type_id": "fake_hide", "placement": "point", "chainage_m": 10.0, "options": opts}
|
||||
)
|
||||
root = str(tmp_path / "project")
|
||||
with pytest.raises(ValueError, match="필수"):
|
||||
repo.save_structures(root, [item({})], base_revision=0) # 보임 = 필수 그대로
|
||||
(store.FOLDER / opt.FILE).write_text('{"fake_hide": {"a": false}}', encoding="utf-8")
|
||||
with pytest.raises(ValueError, match="필수"): # a 는 숨겨 통과 · b 는 여전히 필수
|
||||
repo.save_structures(root, [item({})], base_revision=0)
|
||||
assert (
|
||||
repo.save_structures(root, [item({"b": 3})], base_revision=0) == 1
|
||||
) # 숨긴 a 는 빈 채 저장
|
||||
|
||||
Reference in New Issue
Block a user