Files
Aislo/resources/tester/test_route_polyline_idempotent.py
T
eomsangdonandClaude Opus 5 0ef32b5279 chore(tester): 시험을 resources/tester/ 로 옮김 — 창끼리 건너가게
⚠ **뿌리** — `tmp/` 는 창 사이에 안 건너감(실측 확인: 상대 창이 놓은 `tmp/_sync_probe.txt`
가 시간을 두고 두 번 봐도 안 보임). 그래서 **정본(등록부 스키마)만 건너가고 그것을 읽는
시험은 안 건너가** 오늘 두 번, 같은 시험이 **연 창은 통과·받은 창은 실패**가 됐음.

- `tmp/tests/*` 를 `resources/tester/` 로 **복사**(127 파일). 내용은 **한 줄도 안 고침**
- `tmp/tests` 는 **남겨 둠** — 되돌릴 자리(사용자 지시)
- 실행: `./venv/Scripts/python.exe -m pytest resources/tester/ -q`
  옮기기 전과 **같은 수**: 617 통과 / 22 건너뜀 / 실패 0

⇒ 이제 시험·예외·까닭이 **정본과 함께** 움직임. 오늘 세운 「예외는 정본 스키마에」와 짝임.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 17:12:30 +09:00

54 lines
2.5 KiB
Python

"""[확인]을 여러 번 눌러도 선이 깎이지 않는지 — 노드 왕복이 제자리인가.
왜 (2026-09-07 보조 창 실측) — 같은 노선으로 [확인]을 되풀이했더니 계획노선 정점이
136 → 134 → 119, 노드가 22 → 21 로 계속 줄었다. 원인은 **이미 폴리라인인 것을 다시
단순화**한 것. 원호 위 점이 섞인 선을 단순화하면 꺾임점이 조금씩 지워지고, 그 결과로 만든
선을 또 단순화하기 때문이다. 단순화는 **원본 점군에서 한 번만** 돌아야 한다.
"""
import math
from common_util.common_util_route_polyline import build_planned_polyline
RADIUS = 15.0
def _zigzag() -> list[tuple[float, float]]:
"""꺾임이 뚜렷한 원본 점군 — 3m 간격으로 조밀하게 찍은 지그재그."""
corners = [(0.0, 0.0), (120.0, 0.0), (120.0, 120.0), (260.0, 120.0), (260.0, 240.0)]
points: list[tuple[float, float]] = []
for start, end in zip(corners, corners[1:]):
length = math.dist(start, end)
steps = max(2, int(length // 3))
for step in range(steps):
ratio = step / steps
points.append(
(start[0] + (end[0] - start[0]) * ratio, start[1] + (end[1] - start[1]) * ratio)
)
points.append(corners[-1])
return points
def test_노드를_다시_넣으면_같은_선이_나온다():
"""사용자가 아무것도 안 옮기고 [확인]만 눌렀을 때 = 노드 그대로 왕복."""
first = build_planned_polyline(_zigzag(), min_radius_m=RADIUS)
nodes = [(node.x, node.y) for node in first.nodes]
second = build_planned_polyline(nodes, min_radius_m=RADIUS, simplify=False)
assert [(n.x, n.y) for n in second.nodes] == nodes
assert second.vertices == first.vertices
assert second.curve_count == first.curve_count
third = build_planned_polyline(
[(node.x, node.y) for node in second.nodes], min_radius_m=RADIUS, simplify=False
)
assert third.vertices == first.vertices, "세 번째 왕복에서 선이 달라짐"
def test_옛_방식은_실제로_깎인다():
"""왜 갈래가 필요한지 못박는다 — 폴리라인을 다시 단순화하면 노드가 준다."""
first = build_planned_polyline(_zigzag(), min_radius_m=RADIUS)
# 옛 방식: 폴리라인 정점(원호 포함)을 통째로 다시 단순화
again = build_planned_polyline(first.vertices, min_radius_m=RADIUS)
assert len(again.nodes) != len(first.nodes) or again.vertices != first.vertices