[feat] solution/backend: 일정을 스냅샷에서 읽는다 — 즉석 계산을 잠시 쉬게 한다
This commit is contained in:
1 parent
2824701030
commit
8dba691274
3 files changed
+94
-13
No files matched your search
@@ -0,0 +1,69 @@
|
||||
"""스냅샷의 일정이 payload 로 그대로 나가는가.
|
||||
|
||||
★ `site_payload._local` 은 **순수 함수**다(DB 도 파일도 안 건드린다). 그래서 여기서는
|
||||
스냅샷 dict 를 손으로 만들어 넣는다 — 발행본이 스냅샷과 다른 페이지가 되지 않게 하는
|
||||
그 원칙(`site_payload.to_site_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():
|
||||
"""검증: 스냅샷에 일정이 있을 때.
|
||||
기대결과: payload.local.itineraries 로 모양 그대로 나간다 — 렌더러 계약을 여기서 바꾸지 않는다."""
|
||||
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():
|
||||
"""검증: 좌표와 주변 관광지·맛집이 있어도 알고리즘 일정이 끼지 않는다.
|
||||
기대결과: 스냅샷의 itineraries 만 나간다 — services/itinerary.py 는 잠시 쓰지 않는다
|
||||
(2026-09-11 결정). 되살릴 때 이 테스트를 함께 고친다."""
|
||||
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
|
||||
Reference in new issue
Block a user