feat(D 예정노선): 저장 꼴에 지점 이름 · 선 이름 · 노드 기록 칸 · [저장] 몸 기준점 (PLAN 594-1 · 594-3 · 요구 463)
- 파일 points [{x, y, name?}] · lines[].name? · lines[].nodes?(꼭짓점 수와 같음 · kind free/length/slope/both · length_m · slope_pct) — 칸 없는 옛 파일 그대로 읽힘
- PUT 몸 point_names · site{lon, lat, address?} — 기준점이 바뀌면 같은 트랜잭션에서 projects.site_* 고침(주소 = 서버 VWorld · 못 찾으면 몸 주소)
- 이름 20 자 · 파일 이름 못 쓰는 글자 막음 — 서버 400(name_error) ↔ TS nameError 짝 · 노드 기록 수 틀림 400
- 선 이름 = 붙인 이름 · 없으면 차례 이름(lineNames ↔ line_names 짝 · 내보내기 조각 이름에 이어짐)
- TS 꼴 NodeKind · NodeRecord · PlanLine.name/nodes · BasePoint.name · ServerNetwork.point_names/site · searchPlaces 틀
- 시험 530_3 이름 거울 · 591_2 왕복 · 400 · 기준점
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
조각이 선을 빈틈없이 덮음 · 마크 놓기 · 지우기 · 갈래 차례 밀기 · 갈래 붙은 점 못 뺌 ·
|
||||
서버 꼴 읽기 · 화면 꼴(선 · 마크 · 조각)을 서버 셈(`derive`)이 그대로 받음 ·
|
||||
580 = 종점에서 그은 선 뒤집어 잇기 · 갈래로 붙음 · 꺾임점 옮김 · 지움(마크 비율) ·
|
||||
선 지움 · 방향 바꿈 · 선 통째 연도 · 마크 옮김 · 선 이름 거울(D04 `line_names`).
|
||||
선 지움 · 방향 바꿈 · 선 통째 연도 · 마크 옮김 · 선 이름 거울(D04 `line_names` · 붙인 이름 594-1) ·
|
||||
이름 규칙 거울(`nameError` ↔ `name_error` · 594-1).
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_530_3_plan_logic.py -q
|
||||
"""
|
||||
@@ -101,12 +102,22 @@ const names = [
|
||||
plan.lineNames([{ branch: null }]),
|
||||
plan.lineNames([{ branch: null }, { branch: null }, { branch: { line: "main", vertex: 1 } }]),
|
||||
plan.lineNames([{ branch: null }, { branch: { line: "main", vertex: 1 } }]),
|
||||
plan.lineNames([
|
||||
{ branch: null, name: " 임도 A " },
|
||||
{ branch: null },
|
||||
{ branch: { line: "main", vertex: 1 }, name: "" },
|
||||
]),
|
||||
];
|
||||
const B = String.fromCharCode(92);
|
||||
const NAME_CASES = ["가".repeat(20), "가".repeat(21), " 임도 ", "", "a/b", "a" + B + "b",
|
||||
"a:b", "a*b", "a?b", 'a"b', "a<b", "a>b", "a|b", "a" + String.fromCharCode(9) + "b",
|
||||
"용화-1_(2027)"];
|
||||
const nameErrors = NAME_CASES.map((name) => [name, plan.nameError(name)]);
|
||||
writeFileSync(process.argv[2], JSON.stringify({
|
||||
one, split, tooClose, branched, inserted, blocked, dropped, guard, removed, grown, read,
|
||||
marks: plan.marksOf(branched),
|
||||
empty, joined, sameYear, asBranch, m, movedV, removedV, removeBlocked, lineBlocked, lineGone,
|
||||
reversed, branchFlip, lineYear, markMoved, markClamp, names,
|
||||
reversed, branchFlip, lineYear, markMoved, markClamp, names, nameErrors, NAME_MAX: plan.NAME_MAX,
|
||||
}));
|
||||
"""
|
||||
|
||||
@@ -260,7 +271,23 @@ def test_line_names_mirror(tmp_path: Path) -> None:
|
||||
[{"branch": None}],
|
||||
[{"branch": None}, {"branch": None}, {"branch": {"line": "main", "vertex": 1}}],
|
||||
[{"branch": None}, {"branch": {"line": "main", "vertex": 1}}],
|
||||
[
|
||||
{"branch": None, "name": " 임도 A "},
|
||||
{"branch": None},
|
||||
{"branch": {"line": "main", "vertex": 1}, "name": ""},
|
||||
],
|
||||
]
|
||||
assert got["names"] == [line_names(c) for c in cases]
|
||||
assert got["names"][3] == ["임도 A", "본선 2", "갈래 1"] # 붙인 이름 · 빈 이름 = 차례 이름
|
||||
assert got["names"][1] == ["본선 1", "본선 2", "갈래 1"] # 시점 둘 = 둘째도 본선
|
||||
assert got["names"][2] == ["본선", "갈래 1"] # 옛 꼴 이름 그대로
|
||||
|
||||
|
||||
def test_name_rule_mirror(tmp_path: Path) -> None:
|
||||
"""594-1 이름 규칙 — TS `nameError` ↔ 서버 `name_error` 같은 판정 · 20 자 · 금지 글자."""
|
||||
got = _run_ts(tmp_path)
|
||||
assert got["NAME_MAX"] == server.NAME_MAX == 20
|
||||
for name, error in got["nameErrors"]:
|
||||
assert (error is None) == (server.name_error(name) is None), name
|
||||
ok = {name for name, error in got["nameErrors"] if error is None}
|
||||
assert ok == {"가" * 20, " 임도 ", "", "용화-1_(2027)"}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
- 옛 지점 칸(시점 · 종점 목록 · 한 점 꼴)은 열 때 옮겨 보임.
|
||||
- 핀 끌기 = 그 자리 노선 노드 같이(TS `moveNodesAt` · 붙은 갈래 첫 점 · 다른 점은 그대로).
|
||||
- D02 길 · 단계 · 폴더가 남지 않음.
|
||||
- 594-1 지점 · 선 이름 · 노드 기록 왕복 · 옛 파일 읽힘 · 21 자 · 금지 글자 400 ·
|
||||
594-3 [저장] 몸 기준점 → 등록 칸(바뀔 때만 · 주소 = 서버 다시 찾음).
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_591_2_plan_points.py -q
|
||||
"""
|
||||
@@ -158,6 +160,103 @@ def test_epsg_stays_once_saved(api) -> None:
|
||||
assert got.status_code == 400 # 파일 머리 좌표계 한 곳
|
||||
|
||||
|
||||
# --- 594-1 지점 · 선 이름 · 노드 기록 ---
|
||||
|
||||
NODES = [None, {"kind": "both", "length_m": 20.0, "slope_pct": 8.5}]
|
||||
|
||||
|
||||
def test_names_nodes_round_trip(api) -> None:
|
||||
# 옛 파일(이름 · 기록 칸 없음) 그대로 읽힘
|
||||
store.save_plan(
|
||||
api.state["root"],
|
||||
{**store.empty_plan(5186), "points": [{"x": A[0], "y": A[1]}], "lines": [LINE]},
|
||||
)
|
||||
old = api.get(URL).json()
|
||||
assert "name" not in old["base"]["points"][0] and "name" not in old["network"]["lines"][0]
|
||||
line = {**LINE, "name": " 용화 본선 ", "nodes": NODES}
|
||||
branch = {
|
||||
"id": "branch-1",
|
||||
"vertices": [list(B), [B[0] + 50, B[1]]],
|
||||
"branch": {"line": "main", "vertex": 1},
|
||||
}
|
||||
body = {
|
||||
"epsg": 5186,
|
||||
"points": [list(A), list(B)],
|
||||
"point_names": ["시점", None],
|
||||
"lines": [line, branch],
|
||||
}
|
||||
got = api.put(URL, json=body)
|
||||
assert got.status_code == 200, got.text
|
||||
view = api.get(URL).json()
|
||||
assert [p.get("name") for p in view["base"]["points"]] == ["시점", None]
|
||||
main, side = view["network"]["lines"]
|
||||
assert main["name"] == "용화 본선" and main["nodes"] == NODES
|
||||
assert "name" not in side and "nodes" not in side # 빈 칸 = 옛 꼴 그대로
|
||||
saved = _saved(api)
|
||||
assert saved["points"][1] == {"x": B[0], "y": B[1]}
|
||||
# 이름만 다시 [저장] = 같은 값
|
||||
again = api.put(URL, json={**body, "lines": view["network"]["lines"]}).json()
|
||||
assert again["network"]["lines"] == view["network"]["lines"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"patch",
|
||||
[
|
||||
{"lines": [{**LINE, "name": "가" * 21}]},
|
||||
{"lines": [{**LINE, "name": "a/b"}]},
|
||||
{"lines": [{**LINE, "name": 'a"b'}]},
|
||||
{"point_names": ["시:점"]},
|
||||
{"point_names": ["가" * 21]},
|
||||
{"point_names": ["a", "b"]}, # 지점보다 많음
|
||||
{"lines": [{**LINE, "nodes": [None]}]}, # 꼭짓점 둘 · 기록 하나
|
||||
],
|
||||
)
|
||||
def test_bad_names_nodes_400(api, patch) -> None:
|
||||
body = {"epsg": 5186, "points": [list(A)], "lines": [LINE], **patch}
|
||||
assert api.put(URL, json=body).status_code == 400
|
||||
assert not store.plan_path(api.state["root"]).exists() # 안 씀
|
||||
|
||||
|
||||
def test_name_20_ok_and_bad_kind_422(api) -> None:
|
||||
body = {"epsg": 5186, "points": [list(A)], "point_names": ["가" * 20], "lines": [LINE]}
|
||||
assert api.put(URL, json=body).status_code == 200
|
||||
bad = {**LINE, "nodes": [None, {"kind": "grade", "length_m": 1, "slope_pct": 1}]}
|
||||
assert api.put(URL, json={"epsg": 5186, "lines": [bad]}).status_code == 422
|
||||
|
||||
|
||||
# --- 594-3 [저장] 몸 기준점 → 등록 칸 ---
|
||||
|
||||
|
||||
def test_site_saved_with_network(api, monkeypatch) -> None:
|
||||
written = []
|
||||
|
||||
async def store_site(connection, project_id, site):
|
||||
written.append(site)
|
||||
|
||||
async def place(lon, lat):
|
||||
return {"address": f"주소 {lon:.3f}", "region": "어딘가"}
|
||||
|
||||
monkeypatch.setattr(net, "_store_site", store_site)
|
||||
monkeypatch.setattr(net, "reverse_place", place)
|
||||
same = {"lon": SITE["lon"], "lat": SITE["lat"]}
|
||||
api.put(URL, json={"epsg": 5186, "lines": [LINE], "site": same})
|
||||
api.put(URL, json={"epsg": 5186, "lines": [LINE]})
|
||||
assert written == [] # 그대로 · 빈 값 = 안 씀
|
||||
moved = {"lon": 127.2, "lat": 37.6, "address": "몸 주소"}
|
||||
got = api.put(URL, json={"epsg": 5186, "lines": [LINE], "site": moved}).json()
|
||||
assert written == [{"lon": 127.2, "lat": 37.6, "address": "주소 127.200"}] # 서버가 다시 찾음
|
||||
assert got["base"]["site"] == written[0]
|
||||
|
||||
async def no_place(lon, lat):
|
||||
return {"address": None, "region": None}
|
||||
|
||||
monkeypatch.setattr(net, "reverse_place", no_place)
|
||||
api.put(URL, json={"epsg": 5186, "lines": [LINE], "site": {**moved, "lon": 127.3}})
|
||||
assert written[-1]["address"] == "몸 주소" # 못 찾으면 몸 주소
|
||||
bad = api.put(URL, json={"epsg": 5186, "lines": [LINE], "site": {"lon": 200, "lat": 37}})
|
||||
assert bad.status_code == 422
|
||||
|
||||
|
||||
# --- D02 걷음 ---
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user