fix: 각 정의 검토 반영 — 지금 비 오면 바깥 각 상한(비 소식 조건), 습도 상한, 시간대가 구간과 2시간 이상 겹쳐야 구간 점수, 뜨아·환기·김서림·화장붕괴·냉면·택시·배달·야구·사진·공부·넷플릭스·군밤·연날리기·이불빨래·실내건조·귤·군고구마·붕어빵·눈사람·빙수·캠핑·단풍·해돋이 비중·조건 조정, 새 각 우산·파전·감성노래
This commit is contained in:
1 parent
c0ba463e54
commit
d020d27715
7 files changed
+505
-76
No files matched your search
@@ -49,8 +49,10 @@ def test_current_slot_before_5_is_previous_night():
|
||||
|
||||
|
||||
def test_gak_hidden_in_slots_outside_its_window():
|
||||
parts = slot_results(_defn([{"from": 18, "to": 24}]), DAY, REGION, _rows(), {}, CTX, SUNSET)
|
||||
parts = slot_results(_defn([{"from": 17, "to": 24}]), DAY, REGION, _rows(), {}, CTX, SUNSET)
|
||||
assert set(parts) == {"evening", "night"}
|
||||
# 18시 한 시간만 저녁 구간(16~18시)과 겹치면 저녁 점수는 내지 않는다
|
||||
assert set(slot_results(_defn([{"from": 18, "to": 24}]), DAY, REGION, _rows(), {}, CTX, SUNSET)) == {"night"}
|
||||
|
||||
|
||||
def test_rain_in_evening_lowers_only_later_slots():
|
||||
@@ -91,8 +93,16 @@ def test_ultra_rain_marks_dry_forecast_hours_as_rain():
|
||||
|
||||
|
||||
def test_ultra_rain_lowers_slot_score():
|
||||
defn = _defn([{"from": 10, "to": 17}])
|
||||
defn = _defn([{"from": 9, "to": 17}])
|
||||
by_at = {r.forecast_at: r for r in (_hourly(h) for h in range(5, 30))}
|
||||
rainy = with_ultra_rain(by_at, [RainHour(at=kst_midnight(DAY) + timedelta(hours=10), rain_type=RainType.RAIN, rain_mm=2.0)])
|
||||
dry, wet = (slot_results(defn, DAY, REGION, b, {}, CTX, SUNSET)["morning"].score for b in (by_at, rainy))
|
||||
assert wet < dry
|
||||
|
||||
|
||||
def test_slot_needs_two_overlapping_hours():
|
||||
"""10~17시 각은 아침 구간(5~11시)과 10시 한 시간만 겹쳐서 아침 점수를 내지 않는다. 한 시간짜리 각은 한 시간이면 된다."""
|
||||
by_at = _rows()
|
||||
assert "morning" not in slot_results(_defn([{"from": 10, "to": 17}]), DAY, REGION, by_at, {}, CTX, SUNSET)
|
||||
assert "morning" in slot_results(_defn([{"from": 9, "to": 17}]), DAY, REGION, by_at, {}, CTX, SUNSET)
|
||||
assert "morning" in slot_results(_defn([{"from": 10, "to": 11}]), DAY, REGION, by_at, {}, CTX, SUNSET)
|
||||
@@ -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"]) == 34
|
||||
assert len(body["stories"]) == 38
|
||||
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)
|
||||
|
||||
@@ -92,7 +92,7 @@ async def test_index_detail_has_six_factors_and_rules(fakes):
|
||||
assert body["index"]["code"] == "yajang"
|
||||
assert [f["label"] for f in body["factors"]] == ["기온 알맞음", "비 안 옴", "바람 잔잔", "습도 알맞음", "공기 맑음", "요일 알맞음"]
|
||||
assert sum(f["weight"] for f in body["factors"]) == 100
|
||||
assert body["zero_rules"] == "비 확률 80% 이상이거나 바람 14m/s 이상이면 0점"
|
||||
assert body["zero_rules"] == "비 소식이 있거나 비 확률 70% 이상이거나 바람 14m/s 이상이면 0점"
|
||||
assert body["limit"].startswith("모기")
|
||||
|
||||
|
||||
|
||||
@@ -290,3 +290,21 @@ def test_weather_score_100_only_on_perfect_day():
|
||||
|
||||
good = [_h(h, feels=22.5, prob=10, wind=2.5, hum=62, sunshine_ratio=0.7) for h in range(9, 22)]
|
||||
assert evaluate(WEATHER_SCORE_DEF, [good], replace(perfect, pm25=15)).score < 95
|
||||
|
||||
|
||||
def test_raining_now_caps_even_with_low_rain_prob():
|
||||
"""초단기예보로 비가 들어온 시각은 예보 확률이 낮아도 '비 소식' 상한이 걸린다."""
|
||||
defn = _defn(zero_rules=[{"field": "rain", "op": "==", "value": "yes", "cap": 20}])
|
||||
r = evaluate(defn, [[_h(19, prob=30, rain=RainType.RAIN)]], CTX)
|
||||
assert r.score <= 20 and r.zero_reason == "비 소식이 있어 최대 20점"
|
||||
assert evaluate(defn, [[_h(19, prob=30)]], CTX).zero_reason is None
|
||||
|
||||
|
||||
def test_humidity_cap():
|
||||
defn = _defn(zero_rules=[{"field": "humidity", "op": ">=", "value": 85, "cap": 40}])
|
||||
assert evaluate(defn, [[_h(19, hum=92)]], CTX).zero_reason == "습도 85% 이상이라 최대 40점"
|
||||
assert zero_rules_text([{"field": "rain", "op": "==", "value": "yes"}]) == "비 소식이 있으면 0점"
|
||||
|
||||
|
||||
def test_axis_label_can_be_overridden():
|
||||
assert axis_label("temp", {"temp": {"type": "higher", "label": "덜 추움"}}) == "덜 추움"
|
||||
Reference in new issue
Block a user