feat: 내일 날씨 페이지(/tomorrow/...) 히어로 아래를 내일 것으로 — 내일의 각 5개·내일 3시간 예보·내일 열리는 행사·오늘 소식 버튼(GA tomorrow_to_today), 오늘 피드는 빼서 같은 지역 오늘 페이지와 본문이 97% 겹쳐 구글이 하나만 색인하던 것을 줄임
This commit is contained in:
1 parent
3c58552852
commit
9431dc31c2
11 files changed
+274
-73
No files matched your search
@@ -148,6 +148,8 @@ async def test_hero_tomorrow_and_tomorrow_slots(offline):
|
||||
async with client() as c:
|
||||
hero = (await c.get("/v1/feed", params={"region": REGION})).json()["hero"]
|
||||
assert set(hero["tomorrow"]["weather_slots"]) <= {"morning", "day", "evening", "night"}
|
||||
assert len(hero["tomorrow"]["ranked"]) <= 5 and len(hero["tomorrow"]["events"]) <= 3
|
||||
assert hero["tomorrow"]["top1"] == (hero["tomorrow"]["ranked"][0] if hero["tomorrow"]["ranked"] else None)
|
||||
res = (await c.get("/v1/weather/today", params={"region": REGION, "day": "tomorrow"})).json()
|
||||
assert res["day"] == hero["tomorrow"]["day"]
|
||||
|
||||
|
||||
@@ -210,6 +210,49 @@ def test_feed_events_keeps_every_festival_and_two_of_other_kinds():
|
||||
assert out[:4] == [EventKind.FESTIVAL.value, EventKind.POPUP.value, EventKind.EXHIBITION.value, EventKind.CONCERT.value]
|
||||
|
||||
|
||||
def test_tomorrow_events_keep_same_sido_events_running_that_day():
|
||||
"""내일 페이지 행사: 내일 열리는 같은 시도 행사만, 종류를 섞어 3개까지."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
from common.enums import EventKind
|
||||
from services.feed_service import tomorrow_events
|
||||
from services.week_service import EventItem
|
||||
|
||||
day = date(2026, 10, 31)
|
||||
|
||||
def ev(n, kind, sido="11", start=day, end=day):
|
||||
e = SimpleNamespace(event_id=n, name=f"행사{n}", place_name=f"장소{n}", icon="concert", kind=kind.value, sido_code=sido, start_date=start, end_date=end)
|
||||
return EventItem(event=e, status="live", status_label="진행 중", fit=None)
|
||||
|
||||
items = [
|
||||
ev(1, EventKind.CONCERT), ev(2, EventKind.CONCERT), ev(3, EventKind.FESTIVAL, start=day - timedelta(days=2)),
|
||||
ev(4, EventKind.FESTIVAL, end=day - timedelta(days=1)), ev(5, EventKind.EXHIBITION, sido="41"), ev(6, EventKind.POPUP, start=day + timedelta(days=1)),
|
||||
]
|
||||
out = tomorrow_events(items, "1144000000", day)
|
||||
assert [e.event_id for e in out] == [3, 1, 2]
|
||||
assert out[0].place == "장소3" and out[0].start_date == day - timedelta(days=2)
|
||||
|
||||
|
||||
def test_hero_tomorrow_ranks_in_season_gak_by_tomorrow_score():
|
||||
"""내일의 각: 내일 하루 점수(중요도 반영) 순 5개, 철 지난 각은 빼고, 1위는 top1 과 같다."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
from services.feed_service import _hero_tomorrow
|
||||
|
||||
day = date(2026, 10, 31)
|
||||
|
||||
def item(n, score, in_season=True, priority=1.0):
|
||||
d = SimpleNamespace(index_id=n, code=f"g{n}", name=f"각{n}", icon="sun", priority=priority)
|
||||
trend = [SimpleNamespace(score_date=day - timedelta(days=1), score=100, summary="오늘"), SimpleNamespace(score_date=day, score=score, summary=f"내일{n}")]
|
||||
return SimpleNamespace(definition=d, trend=trend, in_season=in_season)
|
||||
|
||||
board = SimpleNamespace(items=[item(1, 60), item(2, 99, in_season=False), item(3, 90), item(4, 70), item(5, 80), item(6, 50), item(7, 40)],
|
||||
tomorrow_slots={}, tomorrow_why={})
|
||||
hero = _hero_tomorrow(day, board)
|
||||
assert [(g.index_id, g.rank) for g in hero.ranked] == [(3, 1), (5, 2), (4, 3), (1, 4), (6, 5)]
|
||||
assert hero.top1 == hero.ranked[0] and hero.ranked[0].summary == "내일3"
|
||||
|
||||
|
||||
def test_arrange_spreads_many_events_through_whole_feed():
|
||||
"""행사가 앞쪽 절반 자리보다 많으면 끝까지 한 장씩 걸러 끼우고, 남은 건 맨 뒤에 다 붙인다."""
|
||||
from datetime import datetime
|
||||
|
||||
Reference in new issue
Block a user