fix: 지금 구간 각 점수와 '지금' 칸은 지금 시각부터 (이미 지난 시각의 단기예보 비가 남아 우산각 1위·비 아이콘이 나오던 것)

This commit is contained in:
minaChoi committed 2026-10-13 13:33:10 +09:00
1 parent 260ded8c79
commit 0b536e1f90
4 files changed
+43 -8

No files matched your search

+17
View File
@@ -108,3 +108,20 @@ def test_slot_needs_two_overlapping_hours():
assert "morning" not in slot_results(_defn([{"from": 10, "to": 17}]), DAY, REGION, by_at, {}, CTX, SUNSET)
assert "morning" in slot_results(_defn([{"from": 9, "to": 17}]), DAY, REGION, by_at, {}, CTX, SUNSET)
assert "morning" in slot_results(_defn([{"from": 10, "to": 11}]), DAY, REGION, by_at, {}, CTX, SUNSET)
def test_current_slot_skips_passed_hours():
"""13:30이면 낮 구간(11~15시)은 13시부터 본다. 11~12시에만 온 비는 지금 점수를 깎지 않는다. 지난 아침 구간은 그대로."""
defn = _defn([{"from": 5, "to": 24}])
by_at = {r.forecast_at: r for r in (_hourly(h, RainType.RAIN if h in (11, 12) else RainType.NONE) for h in range(5, 30))}
now = datetime(2026, 10, 8, 13, 30, tzinfo=KST)
with_now = slot_results(defn, DAY, REGION, by_at, {}, CTX, SUNSET, now)
without = slot_results(defn, DAY, REGION, by_at, {}, CTX, SUNSET)
assert with_now["day"].score > without["day"].score
assert with_now["morning"].score == without["morning"].score
def test_current_slot_keeps_last_hour():
"""구간 끝 한 시간만 남아도 지금 구간 점수를 낸다."""
now = datetime(2026, 10, 8, 15, 10, tzinfo=KST)
assert "day" in slot_results(_defn([{"from": 9, "to": 17}]), DAY, REGION, _rows(), {}, CTX, SUNSET, now)