fix: 히어로의 지금 값에 초단기실황 반영, 구간 경계 시각의 우산각 '지금 비'

- 히어로가 DB 예보 행을 직접 읽어 실황이 안 들어가던 것 — 지금 시각 행을 관측값으로 덮음. 피드 캐시도 새 시각 실황이 나오는 매시 10분에 끝나게 함
- 낮이 15:20 에 끝나는 날 15:00~15:20 처럼 구간 경계 직전에는 지금 시각 행이 다음 구간 칸에 들어, 화면이 보여 주는 지금 구간의 우산각이 '지금 비'를 놓치던 것 — 우산각의 지금은 화면이 보여 주는 구간 기준으로 정하고 그 줄 문구도 지금 시각 날씨로
This commit is contained in:
skkim committed 2026-11-23 15:43:50 +09:00
1 parent 5ab2381f79
commit 4c24d95991
4 files changed
+61 -8

No files matched your search

+27
View File
@@ -106,6 +106,33 @@ def test_feed_cache_expires_when_ultra_forecast_arrives():
assert feed_ttl_sec(now, sunset) == 25 * 60
def test_feed_cache_expires_when_the_new_hours_observation_arrives():
"""15:02 에 만든 피드는 15시 실황이 나오는 15:10 에 끝나야 한다. 안 그러면 미세먼지(15:20)까지 히어로가 지난 시각 값이다."""
from datetime import datetime
from common.utils.kma_time import KST
from services.feed_service import feed_ttl_sec
now = datetime(2026, 10, 2, 15, 2, tzinfo=KST)
sunset = datetime(2026, 10, 2, 18, 10, tzinfo=KST)
assert feed_ttl_sec(now, sunset) == 8 * 60
@pytest.mark.anyio
async def test_hero_shows_the_observed_current_weather(offline, monkeypatch):
"""예보는 20도·습도 50% 인데 실황이 3.3도·88% 로 관측했으면 히어로의 지금은 관측값이다."""
import services.weather_service as weather_service
async def observed(*_a):
return [{"category": c, "obsrValue": v} for c, v in {"PTY": "0", "REH": "88", "RN1": "0", "T1H": "3.3", "WSD": "2.0"}.items()]
monkeypatch.setattr(weather_service, "fetch_ncst", observed)
monkeypatch.setattr(weather_service, "latest_ncst_base", lambda now: now.replace(minute=0, second=0, microsecond=0)) # 매시 00~10분에도 같게
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
hero = (await client.get("/v1/feed", params={"region": REGION})).json()["hero"]
assert (hero["temp_c"], hero["humidity"]) == (3.3, 88)
def _card(post_type, post_id=1):
from datetime import datetime