fix(B07 표준도): 노선 저장값 일치

B06 계산과 같은 횡단경사 하한을 사용하고, 그리는 노선의 저장값을
도면과 지문에 함께 적용.
This commit is contained in:
2026-10-23 16:22:19 +09:00
parent bda7c319cf
commit 7a971494fc
4 changed files with 119 additions and 15 deletions
@@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
"""517-1 B07 표준 횡단면도 = 그리는 노선의 B06 저장값."""
from __future__ import annotations
import asyncio
import sys
from pathlib import Path
from types import SimpleNamespace
from uuid import uuid4
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from B06_Section import B06_Section_Repository as b06_repository # noqa: E402
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Standard import ( # noqa: E402
MM,
SECTION_LAYER_ID,
build_standard_cross_drawing,
)
from B07_DesignDetail import B07_DesignDetail_Router_Support_Fingerprint as fp # noqa: E402
from config import config_db # noqa: E402
def _standard(cross_slope_pct: float) -> dict:
return {
"soil": {
"road_width_m": 3.0,
"shoulder_left_m": 0.5,
"shoulder_right_m": 0.5,
"cross_slope_pct": {"min": cross_slope_pct, "max": 5.0},
}
}
def test_B06_저장값_3퍼센트로_표준도_선과_숫자를_그림():
drawing = build_standard_cross_drawing("cross_standard", "표준 횡단면도", _standard(3.0))
labels = [
entity["shapeData"]["label"] for entity in drawing["entities"] if entity["type"] == "Text"
]
assert "횡단경사 3%" in labels
outline = next(
entity
for entity in drawing["entities"]
if entity["type"] == "PolyLine" and entity["layerId"] == SECTION_LAYER_ID
)
road = next(
child["shapeData"]
for child in outline["children"]
if child["shapeData"]["startPoint"]["x"] == -2.0 * MM
and child["shapeData"]["endPoint"]["x"] == 2.0 * MM
)
assert road["startPoint"]["y"] == -2.0 * MM * 0.03
assert road["endPoint"]["y"] == 0.0
class _Acquire:
async def __aenter__(self):
return object()
async def __aexit__(self, *exc):
return False
class _Pool:
def acquire(self):
return _Acquire()
def test_노선_둘이면_그리는_노선의_B06_저장값만_읽음(monkeypatch):
standards = {11: _standard(4.0), 22: _standard(3.0)}
async def get_section(_connection, _project_id, route_id):
return {"data": {"options": {"standard_cross_section": standards[route_id]}}}
monkeypatch.setattr(b06_repository, "get_longitudinal_section", get_section)
monkeypatch.setattr(config_db, "get_db_pool", lambda: _Pool())
source = asyncio.run(fp.standard_cross_source(uuid4(), 22))
assert source["soil"]["cross_slope_pct"]["min"] == 3.0
def test_표준도_지문도_그리는_노선값을_씀(monkeypatch, tmp_path):
calls = []
async def standard_source(_project_id, route_id):
calls.append(route_id)
return _standard(3.0)
def fingerprints(_root, _longitudinal, _drawings, sources):
return {"standard": sources["standard"]}
monkeypatch.setattr(fp, "standard_cross_source", standard_source)
monkeypatch.setattr(fp, "compute_fingerprints", fingerprints)
result = asyncio.run(
fp.drawing_fingerprints(
uuid4(),
22,
tmp_path,
tmp_path / "longitudinal.json",
[SimpleNamespace(id="cross_standard", kind="cross_standard")],
{},
)
)
assert calls == [22]
assert result["standard"]["soil"]["cross_slope_pct"]["min"] == 3.0