fix: 초단기예보 강수형태 5 빗방울·6 빗방울눈날림·7 눈날림을 몰라 KeyError 로 피드가 500 — 비·진눈깨비·눈으로 읽음, 테스트가 실제 초단기예보를 부르던 것 막음
This commit is contained in:
1 parent
d020d27715
commit
4daad2ecc5
3 files changed
+15
-1
No files matched your search
Vendored
+3
-1
@@ -11,7 +11,9 @@ VILAGE_URL = "https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getVilag
|
||||
ULTRA_URL = "https://apis.data.go.kr/1360000/VilageFcstInfoService_2.0/getUltraSrtFcst"
|
||||
WARNING_URL = "https://apis.data.go.kr/1360000/WthrWrnInfoService/getPwnCd"
|
||||
_SKY = {"1": Sky.CLEAR, "3": Sky.PARTLY, "4": Sky.CLOUDY}
|
||||
_PTY = {"0": RainType.NONE, "1": RainType.RAIN, "2": RainType.SLEET, "3": RainType.SNOW, "4": RainType.SHOWER}
|
||||
# 단기예보 0~4, 초단기예보는 5 빗방울 · 6 빗방울눈날림 · 7 눈날림이 더 있다
|
||||
_PTY = {"0": RainType.NONE, "1": RainType.RAIN, "2": RainType.SLEET, "3": RainType.SNOW, "4": RainType.SHOWER,
|
||||
"5": RainType.RAIN, "6": RainType.SLEET, "7": RainType.SNOW}
|
||||
_REQUIRED = ("TMP", "SKY", "PTY", "POP", "REH")
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from types import SimpleNamespace
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
import services.now_service as now_service
|
||||
import services.air_service as air_service
|
||||
import services.warning_service as warning_service
|
||||
import services.weather_service as weather_service
|
||||
@@ -51,6 +52,7 @@ def fakes(monkeypatch):
|
||||
}]))
|
||||
monkeypatch.setattr(warning_service, "fetch_warning_events", lambda *a: _async([]))
|
||||
monkeypatch.setattr(weather_service, "fetch_mid", lambda *a: _async(_mid()))
|
||||
monkeypatch.setattr(now_service, "fetch_ultra", lambda *a: _async([]))
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
|
||||
@@ -72,3 +72,13 @@ def test_ieyo_particle():
|
||||
assert ieyo("환기") == "환기예요"
|
||||
assert ieyo("야장각") == "야장각이에요"
|
||||
assert ieyo("아아→뜨아") == "아아→뜨아예요"
|
||||
|
||||
|
||||
def test_parse_ultra_reads_drizzle_codes():
|
||||
"""초단기예보에만 있는 5 빗방울 · 6 빗방울눈날림 · 7 눈날림."""
|
||||
items = [
|
||||
{"fcstDate": "20261013", "fcstTime": f"{h:02d}00", "category": c, "fcstValue": v}
|
||||
for h, pty in ((10, "5"), (11, "6"), (12, "7"))
|
||||
for c, v in [("PTY", pty), ("RN1", "1mm 미만"), ("T1H", "17")]
|
||||
]
|
||||
assert [p["rain_type"] for p in parse_ultra(items)] == [RainType.RAIN, RainType.SLEET, RainType.SNOW]
|
||||
Reference in new issue
Block a user