feat: 날씨 점수를 깐깐하게(96→92, 100점은 모든 조건이 완벽할 때만, 낮은 점수도 8/9로) — 히어로에 구간별 점수 근거(조건·비중·조건 점수·지금 값) weather_why

This commit is contained in:
minaChoi committed 2026-10-21 13:55:15 +09:00
1 parent b5c280ca3c
commit 8f95519cb6
5 files changed
+67 -9

No files matched your search

+23
View File
@@ -340,3 +340,26 @@ def test_umbrella_lost_needs_rain_that_stopped():
assert evaluate(defn, [[_h(13), _h(14)]], after_rain).score >= 80
assert evaluate(defn, [[_h(13), _h(14)]], CTX).zero_reason == "앞서 내린 비가 없어 0점"
assert evaluate(defn, [[_h(10, rain=RainType.RAIN)]], replace(CTX, rain_hours=frozenset({9, 10}))).score == 0
def test_weather_score_is_strict_near_top():
"""좋은 날(96)도 92 수준, 100점은 모든 조건이 완벽할 때만. 낮은 점수도 조금씩 내려간다."""
from services.index_service import strict_weather
assert strict_weather(100) == 100
assert strict_weather(96) == 92
assert strict_weather(99) < 100
assert strict_weather(75) < 75
scores = [strict_weather(s) for s in range(101)]
assert scores == sorted(scores)
def test_weather_why_lists_every_condition_heaviest_first():
from services.index_service import WEATHER_SCORE_DEF, weather_why
ctx = Context(day=date(2026, 10, 2), is_holiday=False, pm25=12, air_label="좋음", moon=0, sunset_score=None, wind_warning=False, lookahead_rain_prob=0)
r = evaluate(WEATHER_SCORE_DEF, [[_h(h, feels=19.0, prob=0, wind=2.0, hum=55, sunshine_ratio=0.9) for h in range(9, 22)]], ctx)
why = weather_why(r)
assert [w.label for w in why] == ["기온", "비", "햇볕", "바람", "습도", "미세먼지"]
assert sum(w.weight for w in why) == 100
assert why[0].note.startswith("체감 19°")