fix: 미세먼지 포스트 — 비 오는데 '창문 활짝 열어도 돼요'라던 것, 비 오면 '창문은 닫아 둬요'. 수치(㎍/㎥) 대신 등급만

This commit is contained in:
minaChoi committed 2026-10-13 09:59:42 +09:00
1 parent a8871b9231
commit 2621db0450
2 files changed
+12 -7

No files matched your search

+7 -4
View File
@@ -72,7 +72,7 @@ async def test_feed_assembles_hero_stories_posts_and_bands(offline):
assert body["bands"]["events"][0]["image_credit"] == "ⓒ한국관광공사"
assert "미세먼지" not in weather["caption"]
air = next(p for p in body["posts"] if p["post_type"] == PostType.AIR.value)
assert [(r["label"], r["value"]) for r in air["slides"][0]["rows"]] == [("초미세먼지", "10㎍/㎥ · 좋음"), ("미세먼지", "20㎍/㎥ · 좋음")]
assert [(r["label"], r["value"]) for r in air["slides"][0]["rows"]] == [("초미세먼지", "좋음"), ("미세먼지", "좋음")]
event = next(p for p in body["posts"] if p["post_type"] == PostType.EVENT.value)
assert event["slides"][0]["eyebrow"].startswith("가까운 행사 · ")
@@ -275,7 +275,7 @@ def test_text_helpers_short_day_and_compass():
assert compass(263) == "서" and compass(247) == "서남서"
def _air(pm25, pm10, measured_hours_ago=0):
def _air(pm25, pm10, measured_hours_ago=0, rain=False):
from datetime import datetime
from types import SimpleNamespace
@@ -285,7 +285,7 @@ def _air(pm25, pm10, measured_hours_ago=0):
now = datetime(2026, 10, 2, 9, 30, tzinfo=KST)
air = None if pm25 is None and pm10 is None else SimpleNamespace(
station_name="테스트", pm25=pm25, pm10=pm10, measured_at=now.replace(minute=0) - timedelta(hours=measured_hours_ago))
ctx = SimpleNamespace(now=now, region=SimpleNamespace(short_name="종로구"), now_w=SimpleNamespace(air=air))
ctx = SimpleNamespace(now=now, region=SimpleNamespace(short_name="종로구"), now_w=SimpleNamespace(air=air, will_rain_2h=rain))
return FeedService._air(None, _base() | {"post_type": PostType.AIR}, ctx)
@@ -294,8 +294,11 @@ def test_air_post_shows_both_values_and_advice_only_when_bad():
assert [r.label for r in good.slides[0].rows] == ["초미세먼지", "미세먼지"] and good.title == "미세먼지 좋음"
bad = _air(40, 60)
assert bad.title == "미세먼지 나쁨" and bad.slides[0].rows[-1].label == "이렇게 해요"
wet = _air(10, 20, rain=True)
assert "창문은 닫아" in wet.slides[0].line and wet.icon == "umbrella"
assert "창문은 닫아" not in _air(40, 60, rain=True).slides[0].line
very = _air(20, 160)
assert very.title == "미세먼지 매우나쁨" and "측정소" in very.caption and very.slides[0].rows[1].value == "160㎍/㎥ · 매우나쁨"
assert very.title == "미세먼지 매우나쁨" and "측정소" in very.caption and very.slides[0].rows[1].value == "매우나쁨"
def test_air_post_off_without_fresh_data():