From c0ba463e54b0cbbb4fdb11d487768dc2786b1863 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Tue, 13 Oct 2026 09:44:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B6=88=EC=BE=8C=EC=A7=80=EC=88=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EC=83=81=EC=B2=AD=EC=B2=98=EB=9F=BC=206~9?= =?UTF-8?q?=EC=9B=94=EC=97=90=EB=A7=8C=20=ED=9E=88=EC=96=B4=EB=A1=9C?= =?UTF-8?q?=EC=97=90=20=ED=91=9C=EC=8B=9C=20=E2=80=94=20=EC=84=A0=EC=84=A0?= =?UTF-8?q?=ED=95=9C=20=EC=B2=A0=EC=97=94=20=EB=B9=84=20=EC=98=A4=EA=B3=A0?= =?UTF-8?q?=20=EC=8A=B5=ED=95=B4=EB=8F=84=20'=EC=BE=8C=EC=A0=81'=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=82=98=EC=99=80=EC=84=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/hero_stats.py | 5 +++-- backend/tests/test_hero_stats.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/services/hero_stats.py b/backend/services/hero_stats.py index 60ac7cc..cfb75f8 100644 --- a/backend/services/hero_stats.py +++ b/backend/services/hero_stats.py @@ -11,6 +11,7 @@ Tone = Literal["normal", "warn", "rain"] UV_HIGH = 6.0 MUGGY_DI = 75 # 불쾌지수 '불쾌'가 시작되는 값 +DISCOMFORT_MONTHS = range(6, 10) # 기상청처럼 6~9월에만. 더위 지표라 선선한 철엔 비 와도 '쾌적'으로 나온다 HUMID_DRY, HUMID_WET = 30, 60 # 습도 % : 이 아래 건조, 이 위 습함 TEMP_SWING_C = 10.0 WIND_CHILL_C = 3.0 @@ -66,11 +67,11 @@ def humidity_label(h: int) -> str: def hero_status(x: HeroInput) -> list[HeroStatItem]: - """히어로 상태 한 줄: 습도·불쾌지수·자외선(해 있을 때, 저녁 포함)·미세먼지를 단계 이름으로. 값이 없는 칸은 뺀다. 조심할 것만 warn.""" + """히어로 상태 한 줄: 습도·불쾌지수(6~9월)·자외선(해 있을 때, 저녁 포함)·미세먼지를 단계 이름으로. 값이 없는 칸은 뺀다. 조심할 것만 warn.""" out: list[HeroStatItem] = [] if x.humidity is not None: out.append(HeroStatItem("humidity", "muggy", "습도", humidity_label(x.humidity))) - if x.discomfort is not None: + if x.discomfort is not None and x.now.month in DISCOMFORT_MONTHS: out.append(HeroStatItem("discomfort", "muggy", "불쾌지수", discomfort_label(x.discomfort), "warn" if x.discomfort >= MUGGY_DI else "normal")) if not x.after_dark and x.uv is not None: out.append(HeroStatItem("uv", "glasses", "자외선", uv_label(x.uv), "warn" if x.uv >= UV_HIGH else "normal")) diff --git a/backend/tests/test_hero_stats.py b/backend/tests/test_hero_stats.py index 043b99b..4749aff 100644 --- a/backend/tests/test_hero_stats.py +++ b/backend/tests/test_hero_stats.py @@ -53,12 +53,19 @@ def _status(x: HeroInput) -> list[tuple[str, str, str]]: def test_status_line_has_four_by_day_and_warns_only_caution(): - x = HeroInput(now=NOW, night=False, humidity=55, discomfort=75, uv=4.2, air=AirGrade.GOOD) + summer = datetime(2026, 7, 7, 14, 20, tzinfo=KST) + x = HeroInput(now=summer, night=False, humidity=55, discomfort=75, uv=4.2, air=AirGrade.GOOD) assert _status(x) == [("습도", "보통", "normal"), ("불쾌지수", "불쾌", "warn"), ("자외선", "보통", "normal"), ("미세먼지", "좋음", "normal")] - x = HeroInput(now=NOW, night=False, humidity=72, discomfort=60, uv=6.0, air=AirGrade.BAD) + x = HeroInput(now=summer, night=False, humidity=72, discomfort=60, uv=6.0, air=AirGrade.BAD) assert _status(x) == [("습도", "습함", "normal"), ("불쾌지수", "쾌적", "normal"), ("자외선", "높음", "warn"), ("미세먼지", "나쁨", "warn")] +def test_status_line_shows_discomfort_only_june_to_september(): + """불쾌지수는 더위 지표라 10월 비 오는 날에도 '쾌적'이 나온다. 기상청처럼 6~9월에만.""" + x = HeroInput(now=NOW, night=False, humidity=95, discomfort=66, uv=1.0, air=AirGrade.GOOD) + assert [s.label for s in hero_status(x)] == ["습도", "자외선", "미세먼지"] + + def test_status_line_drops_uv_at_night_and_missing_values(): assert _status(HeroInput(now=NOW, night=True, after_dark=True, humidity=25, uv=3.0, air=AirGrade.NORMAL)) == [("습도", "건조", "normal"), ("미세먼지", "보통", "normal")] # 저녁 구간(night=True, 아직 해 있음)엔 자외선이 남는다