From 4daad2ecc5ca299d7466b71456439e12fcf2f5d6 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Tue, 13 Oct 2026 09:49:22 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B4=88=EB=8B=A8=EA=B8=B0=EC=98=88?= =?UTF-8?q?=EB=B3=B4=20=EA=B0=95=EC=88=98=ED=98=95=ED=83=9C=205=20?= =?UTF-8?q?=EB=B9=97=EB=B0=A9=EC=9A=B8=C2=B76=20=EB=B9=97=EB=B0=A9?= =?UTF-8?q?=EC=9A=B8=EB=88=88=EB=82=A0=EB=A6=BC=C2=B77=20=EB=88=88?= =?UTF-8?q?=EB=82=A0=EB=A6=BC=EC=9D=84=20=EB=AA=B0=EB=9D=BC=20KeyError=20?= =?UTF-8?q?=EB=A1=9C=20=ED=94=BC=EB=93=9C=EA=B0=80=20500=20=E2=80=94=20?= =?UTF-8?q?=EB=B9=84=C2=B7=EC=A7=84=EB=88=88=EA=B9=A8=EB=B9=84=C2=B7?= =?UTF-8?q?=EB=88=88=EC=9C=BC=EB=A1=9C=20=EC=9D=BD=EC=9D=8C,=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EC=8B=A4=EC=A0=9C=20=EC=B4=88?= =?UTF-8?q?=EB=8B=A8=EA=B8=B0=EC=98=88=EB=B3=B4=EB=A5=BC=20=EB=B6=80?= =?UTF-8?q?=EB=A5=B4=EB=8D=98=20=EA=B2=83=20=EB=A7=89=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/external/kma.py | 4 +++- backend/tests/test_index_api.py | 2 ++ backend/tests/test_now_parse.py | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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]