Files
Aislo/resources/tester/test_141_3_b07_plan_basin.py
T
eomsangdonandClaude Opus 5.5 24b45655e9 feat(B07): 평면도 조각 배수유역 경계 · 유역 번호 — 장 범위로 자름(141-3)
- 조각 둘 더함 — 「배수유역 경계」(유역도 해치 + 테두리) · 「유역 번호」(유역도 배지) · 어느 평면도 종류에나 체크로
- 세부유역 읽기를 metric_basins 로 떼어 유역도 · 평면도 공용 · 장 범위로 잘라 번호는 유역도와 같게
- 번호 배지는 글 자리 잡기의 장애물 · 새 test_141_3

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01STqEqztUthVFBmEP18wBSz
2026-10-09 15:12:34 +09:00

70 lines
2.8 KiB
Python

# -*- coding: utf-8 -*-
"""141-3 평면도 조각 「배수유역 경계」 · 「유역 번호」 — 세부유역을 장 범위로 잘라 유역도 해치 · 배지로.
견본: 유역 1 = 장 안 정사각 · 유역 2 = 장 경계에 걸침(잘림) · 유역 3 = 장 밖(빠짐).
"""
from __future__ import annotations
from types import SimpleNamespace
from B07_DesignDetail import B07_DesignDetail_Router_Support_Basin as basin
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_PlanKinds import (
PIECE_IDS,
build_plan_kind_drawing,
layer_id,
)
from B07_DesignDetail.B07_DesignDetail_Router_PlanKinds import PIECES
BOX = (0.0, 0.0, 100.0, 100.0)
BASINS = [
{"ring": [(10, 10), (40, 10), (40, 40), (10, 40), (10, 10)], "props": {"index": 1}},
{"ring": [(80, 50), (120, 50), (120, 90), (80, 90), (80, 50)], "props": {"index": 2}},
{"ring": [(300, 300), (320, 300), (320, 320), (300, 300)], "props": {"index": 3}},
]
def _pieces(monkeypatch) -> dict:
monkeypatch.setattr(basin, "metric_basins", lambda _context: BASINS)
return basin.plan_basin_pieces(SimpleNamespace(), BOX)
def test_장_범위로_자르고_번호는_유역도와_같다(monkeypatch):
pieces = _pieces(monkeypatch)
rings = pieces["basin"]["items"]
assert [item["number"] for item in rings] == [1, 2] # 장 밖 3 은 빠짐
clipped = rings[1]["ring"]
assert max(x for x, _y in clipped) == 100.0 # 장 경계에서 잘림
numbers = {item["number"]: item["center"] for item in pieces["basin_no"]["items"]}
assert set(numbers) == {1, 2}
x, y = numbers[2]
assert 80 <= x <= 100 and 50 <= y <= 90 # 잘린 조각 안
def test_유역_저장본_없으면_빈_조각(monkeypatch):
def missing(_context):
raise FileNotFoundError
monkeypatch.setattr(basin, "metric_basins", missing)
assert basin.plan_basin_pieces(SimpleNamespace(), BOX) == {
"basin": {"items": []},
"basin_no": {"items": []},
}
def test_어느_평면도에나_조각_체크(monkeypatch):
assert {"basin", "basin_no"} <= set(PIECE_IDS)
assert ("basin", "배수유역 경계", False) in PIECES and (
"basin_no",
"유역 번호",
False,
) in PIECES
drawing = build_plan_kind_drawing("plan_x", "평면도(x)", BOX, _pieces(monkeypatch), 1200)
hatches = [e for e in drawing["entities"] if e["layerId"] == layer_id("basin")]
assert [e["type"] for e in hatches].count("Hatch") == 2
badges = [e for e in drawing["entities"] if e["layerId"] == layer_id("basin_no")]
assert sorted(e["shapeData"]["label"] for e in badges if e["type"] == "Text") == ["1", "2"]
assert len({e["id"] for e in drawing["entities"]}) == len(drawing["entities"])
names = {layer["id"]: layer["name"] for layer in drawing["layers"]}
assert names[layer_id("basin")] == "배수유역 경계"