feat: 각 7개 추가 (골프·집콕·낚시·드라이브·연날리기·물놀이·김장)

This commit is contained in:
minaChoi committed 2026-10-08 09:05:18 +09:00
1 parent e8382f450b
commit b130b32f0b
15 files changed
+726 -13

No files matched your search

+1 -1
View File
@@ -58,7 +58,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"]) == 27
assert len(body["stories"]) == 34
weather = next(p for p in body["posts"] if p["post_type"] == PostType.WEATHER.value)
assert [s["kind"] for s in weather["slides"]] == ["hours", "hours"]
assert len(weather["slides"][0]["hours"]) == 8
+2 -2
View File
@@ -51,11 +51,11 @@ def fakes(monkeypatch):
@pytest.mark.anyio
async def test_index_list_ranks_all_27_with_today_tomorrow_weekend_trend(fakes):
async def test_index_list_ranks_all_34_with_today_tomorrow_weekend_trend(fakes):
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
body = (await client.get("/v1/index/list", params={"region": REGION})).json()
assert body["result"]["success"] is True
assert len(body["items"]) == 27 and len(body["top3"]) == 3
assert len(body["items"]) == 34 and len(body["top3"]) == 3
scores = [i["score"] for i in body["items"]]
assert scores == sorted(scores, reverse=True)
today = now_kst().date()
+42 -1
View File
@@ -1,10 +1,14 @@
import json
from dataclasses import replace
from datetime import date, datetime, timezone
from pathlib import Path
from types import SimpleNamespace
import pytest
from common.enums import RainType, Sky
from services.calc.index_calc import (
OUTING_HOURS, Context, DayForecast, Hour, axis_label, estimate, evaluate, hour_temp, outing, outing_estimate, rain_score, sun_score, temp_score,
OUTING_HOURS, Context, DayForecast, Hour, air_score, axis_label, estimate, evaluate, hour_temp, outing, outing_estimate, rain_score, sun_score, temp_score,
uv_score, view_score, zero_rules_text,
)
from services.calc.moon import illumination
@@ -222,3 +226,40 @@ def test_outing_estimate_from_mid_forecast():
assert r.reason.startswith("비 20% · 낮 ")
assert outing_estimate(_fc(pm=60)).score <= 30
assert outing_estimate(_fc(lo=None, hi=None)) is None
def test_air_rule_can_reverse_so_dusty_air_scores_high():
rule = {"zero": 15, "full": 75}
assert air_score(80, None, rule)[0] == 100 and air_score(10, None, rule)[0] == 0
assert air_score(10, None)[0] == 100
assert axis_label("air", {"air": rule}) == "공기 탁함" and axis_label("air", {}) == "공기 맑음"
_SEED = {x["code"]: SimpleNamespace(**x) for x in json.loads((Path(__file__).parents[1] / "seed" / "index_definition.json").read_text(encoding="utf-8"))}
_SAT, _WED = date(2026, 10, 10), date(2026, 10, 7)
def _seed_score(code, day=_SAT, pm25=10, **hour):
d = _SEED[code]
windows = [[_h(h, **hour) for h in range(w["from"], w["to"])] for w in d.windows]
return evaluate(d, windows, replace(CTX, day=day, pm25=pm25)).score
@pytest.mark.parametrize("code, good, bad", [
("golf", dict(feels=19.0, wind=2.0, hum=45), dict(feels=18.0, prob=80, rain=RainType.RAIN)),
("jipkok", dict(feels=4.0, prob=90, rain=RainType.RAIN, wind=7.0, hum=85), dict(feels=20.0, wind=1.0, hum=40)),
("fishing", dict(feels=22.0, wind=3.0), dict(feels=17.0, wind=11.0)),
("drive", dict(feels=23.0, wind=4.0, hum=45, visibility_km=18.0), dict(feels=18.0, prob=80, rain=RainType.RAIN, visibility_km=5.0)),
("kite", dict(feels=19.0, wind=6.0), dict(feels=14.0, wind=0.5)),
("waterplay", dict(feels=28.0, wind=3.0, sunshine_ratio=0.7), dict(feels=18.0, wind=2.0, sunshine_ratio=0.3)),
("kimjang", dict(feels=9.0, wind=3.0), dict(feels=20.0, wind=2.0)),
])
def test_new_gak_good_day_high_bad_day_low(code, good, bad):
assert 80 <= _seed_score(code, pm25=60 if code == "jipkok" else 10, **good) < 100
assert _seed_score(code, **bad) <= 30
def test_new_gak_100_only_when_every_factor_is_perfect():
perfect = dict(feels=19.5, wind=1.0, hum=35)
assert _seed_score("golf", **perfect) == 100
assert _seed_score("golf", day=_WED, **perfect) < 100