diff --git a/backend/services/external/kma.py b/backend/services/external/kma.py index 76c3c52..52de55a 100644 --- a/backend/services/external/kma.py +++ b/backend/services/external/kma.py @@ -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") diff --git a/backend/tests/test_index_api.py b/backend/tests/test_index_api.py index dacdb5b..344fa4e 100644 --- a/backend/tests/test_index_api.py +++ b/backend/tests/test_index_api.py @@ -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 diff --git a/backend/tests/test_now_parse.py b/backend/tests/test_now_parse.py index b4e4cc7..4264b2f 100644 --- a/backend/tests/test_now_parse.py +++ b/backend/tests/test_now_parse.py @@ -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]