Compare commits

..
2 Commits
5 changed files with 144 additions and 2 deletions

No files matched your search

+128
View File
@@ -3616,5 +3616,133 @@
"sort_order": 49,
"priority": 3,
"months": []
},
{
"code": "trot",
"name": "트로트각",
"icon": "picnic",
"category": 1,
"is_fun": true,
"is_core": false,
"has_detail": true,
"description": "오전 10시~오후 5시, 나들이 가며 트로트 크게 틀고 싶은 정도",
"windows": [
{
"from": 10,
"to": 17
}
],
"weight_temp": 30,
"weight_rain": 25,
"weight_wind": 0,
"weight_humidity": 0,
"weight_air": 0,
"weight_uv": 0,
"weight_sun": 15,
"weight_view": 0,
"weight_time": 30,
"factor_rules": {
"temp": {
"type": "range",
"lo": 15,
"hi": 25
},
"rain": {
"dir": "dry"
},
"wind": {
"type": "ignore"
},
"humidity": {
"type": "ignore"
},
"sun": {
"zero": 0.2,
"full": 0.9
},
"time": {
"type": "weekday",
"sat": 100,
"sun": 100,
"holiday": 100,
"default": 40
}
},
"zero_rules": [
{
"field": "rain",
"op": "==",
"value": "yes",
"cap": 20
}
],
"limit_description": "노래 취향은 반영하지 못해요",
"sentences": {
"0": "오늘은 조용히 집에서 쉬어요.",
"30": "날은 그럭저럭, 흥얼흥얼 한 곡만.",
"60": "볕 좋은 날, 꺾기 한 소절 나와요.",
"80": "관광버스 부르는 날씨, 트로트 메들리 시작!"
},
"sort_order": 50,
"priority": 3,
"months": []
},
{
"code": "singing_rain",
"name": "싱잉인더레인각",
"icon": "umbrella",
"category": 1,
"is_fun": true,
"is_core": false,
"has_detail": true,
"description": "오후 5시~10시, 비 오는 날 우산 쓰고 노래하며 걷기 좋은 정도",
"windows": [
{
"from": 17,
"to": 22
}
],
"weight_temp": 30,
"weight_rain": 50,
"weight_wind": 15,
"weight_humidity": 0,
"weight_air": 0,
"weight_uv": 0,
"weight_sun": 0,
"weight_view": 0,
"weight_time": 5,
"factor_rules": {
"temp": {
"type": "range",
"lo": 15,
"hi": 25
},
"rain": {
"dir": "wet"
},
"wind": {
"type": "calm",
"ok": 3,
"limit": 10
},
"humidity": {
"type": "ignore"
},
"time": {
"type": "fixed",
"value": 100
}
},
"zero_rules": [],
"limit_description": "빗길 미끄러움은 반영하지 못해요",
"sentences": {
"0": "비가 없어요. 노래는 다음 비 오는 날에!",
"30": "빗방울은 조금, 콧노래 정도만.",
"60": "우산 들고 첨벙첨벙 걷기 좋은 비예요.",
"80": "포근한 빗속, 우산 돌리며 노래하고 싶은 밤!"
},
"sort_order": 51,
"priority": 3,
"months": []
}
]
+3 -1
View File
@@ -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")
+1 -1
View File
@@ -61,7 +61,7 @@ async def test_feed_assembles_hero_stories_posts_and_bands(offline):
body = (await client.get("/v1/feed", params={"region": REGION})).json()
assert body["result"]["success"] is True
assert body["hero"]["temp_c"] == 20 and body["hero"]["top1"]["rank"] == 1 and "top3" not in body["hero"]
assert len(body["stories"]) == 38
assert len(body["stories"]) == 40
assert body["hero"]["weather_score"] == body["hero"]["weather_slots"][body["slot"]]
assert all(g["slots"][body["slot"]] == g["score"] and g["slot_ranks"][body["slot"]] == g["rank"] for g in body["stories"] if g["active"])
weather = next(p for p in body["posts"] if p["post_type"] == PostType.WEATHER.value)
+2
View File
@@ -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
+10
View File
@@ -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]