o2o-site-AEO/solution/backend/tests/test_itinerary_payload.py
Mina Choi 11d30bb3d1 [chore] solution,admin,ontology: 코드 주석을 한 줄로 — 히스토리 주석 삭제
여러 줄 주석이 설명보다 경위(예전·실측·지적)를 적고 있어 읽는 사람이 결론을 찾기 어려웠다.

- ts·tsx·js·mjs·css·py 478개: 여러 줄 주석은 첫 문장 한 줄로, 과거형·날짜 문장은 삭제
- 주석 위치는 TypeScript 파서·파이썬 tokenize/ast 로 찾는다 — 문자열 안의 # · /* 는 건드리지 않는다
- eslint·ts·noqa·type: ignore 같은 지시 주석은 그대로 둔다

파이썬 275개 정리 전후 AST 동일, TS 298개 주석 뺀 토큰 동일(빈 JSX 주석 10곳만 차이).
site·frontend·admin tsc, site vitest 105 passed

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 16:05:19 +09:00

59 lines
2.5 KiB
Python

"""스냅샷의 일정이 payload 로 그대로 나가는가."""
from services.site_payload import _local
def _course(name: str, duration: str) -> dict:
return {
"name": name, "duration": duration, "audience": "누구에게나", "why": "이유.",
"days": [{"label": "1일차", "startTime": "14:00",
"stops": [{"name": "장소", "minutes": 60, "moveMinutes": 10,
"searchQuery": "장소", "latitude": 35.99, "longitude": 126.71}]}],
}
def test_itineraries_pass_through_untouched():
"""검증: 스냅샷에 일정이 있을 때."""
snapshot_local = {
"region_code": "52군산시",
"contents": [],
"itineraries": [_course("코스A", "1박 2일"), _course("코스B", "2박 3일")],
}
local, _synced = _local(snapshot_local, 35.98642, 126.70612)
assert [i["name"] for i in local["itineraries"]] == ["코스A", "코스B"]
assert local["itineraries"][0]["days"][0]["stops"][0]["latitude"] == 35.99
def test_no_itineraries_key_when_empty():
"""검증: 일정이 없을 때."""
local, _synced = _local({"region_code": "52군산시", "contents": [], "itineraries": []}, 35.98, 126.70)
assert "itineraries" not in local
def test_old_snapshot_without_the_key_does_not_break():
"""검증: 이 기능 전에 구운 스냅샷(키가 아예 없다)."""
local, _synced = _local({"region_code": "52군산시", "contents": []}, 35.98, 126.70)
assert "itineraries" not in local
def test_non_dict_entries_are_dropped():
"""검증: body 에 dict 가 아닌 것이 섞였을 때."""
snapshot_local = {"contents": [], "itineraries": [_course("코스A", "1박 2일"), "깨진 값", None]}
local, _synced = _local(snapshot_local, 35.98, 126.70)
assert [i["name"] for i in local["itineraries"]] == ["코스A"]
def test_distance_based_algorithm_is_not_used_anymore():
"""검증: 좌표와 주변 관광지·맛집이 있어도 알고리즘 일정이 끼지 않는다."""
snapshot_local = {
"contents": [
{"content_type": 3, "title": "관광지", "latitude": 35.99, "longitude": 126.71,
"body": {"name": "관광지", "category": "관광지"}},
{"content_type": 4, "title": "맛집", "latitude": 35.98, "longitude": 126.70,
"body": {"name": "맛집", "category": "맛집"}},
],
"itineraries": [],
}
local, _synced = _local(snapshot_local, 35.98642, 126.70612)
assert "itineraries" not in local