chore: main 병합 — 지금 날씨 점수 보정을 바꾸기 표로 통일

- index_service.py 충돌: main 의 오늘·내일 날씨 점수 계산은 그대로 쓰고, 보정만 strict_weather 에서 구간별 바꾸기 표(weather_slot_scores)로 바꿈
- weather_slot_scores 는 main 의 weather_why 가 쓰는 점수 근거(factors)를 그대로 둔 Result 를 돌려줌
- strict_weather 와 그 테스트(test_weather_score_is_strict_near_top) 삭제 (바꾸기 표로 통일하기로 정함)
- test_board_activates_gak_outside_its_time_window 의 ensure 스텁을 main 의 {날짜: {구간: Result}} 모양으로 맞춤
This commit is contained in:
skkim committed 2026-10-22 13:58:36 +09:00
commit 621a0cf90d
133 files changed
+8963 -489

No files matched your search

+41 -4
View File
@@ -156,6 +156,27 @@ def test_arrange_orders_by_slot_and_keeps_same_types_apart():
assert night[:3] == [PostType.ALERT, PostType.WEATHER, PostType.TOMORROW] and night[-1] is PostType.QUOTE
def test_arrange_puts_shareable_cards_before_plain_info():
"""주말·노을·행사는 앞쪽 절반, 공기·자외선·상식은 각 뒤로."""
from datetime import datetime
from common.utils.kma_time import KST
from services.feed_service import arrange
sunset = datetime(2026, 10, 1, 18, 10, tzinfo=KST)
cards = [_card(t, n) for n, t in enumerate([
PostType.WEATHER, PostType.ALERT, PostType.GAK, PostType.GAK, PostType.GAK, PostType.SUNSET, PostType.TOMORROW, PostType.WEEK,
PostType.EVENT, PostType.EVENT, PostType.SEASON, PostType.TIP, PostType.QUOTE, PostType.WEEKEND_PLAN, PostType.AIR, PostType.UV, PostType.MOON,
])]
for slot, h in (("morning", 8), ("day", 13), ("evening", 17), ("evening", 19), ("night", 22)):
out = [c.post_type for c in arrange(cards, slot, datetime(2026, 10, 1, h, tzinfo=KST), sunset, False, "2026-10-01:1114000000")]
half = len(out) // 2
assert PostType.SUNSET in out[:half] and PostType.WEEK in out[:half], (slot, out)
assert all(i < half + 2 for i, t in enumerate(out) if t is PostType.EVENT), (slot, out)
first_gak = out.index(PostType.GAK)
assert all(out.index(t) > first_gak for t in (PostType.AIR, PostType.TIP) if t in out), (slot, out)
def test_arrange_scatters_up_to_three_events_same_spot_all_day():
from datetime import datetime
@@ -367,14 +388,14 @@ async def test_feed_has_day_trip_card_with_city_event(offline, monkeypatch):
assert event["line"] == "강릉 커피축제" and event["image"] == "https://tong.visitkorea.or.kr/c.jpg"
def test_gak_caption_starts_with_score_band_sentence():
def test_gak_band_sentence_moves_to_slide_and_caption_keeps_hours():
"""점수 구간 설명 문장은 슬라이드(say)에 두고, 글 설명엔 내일 점수나 하기 좋은 때만."""
from types import SimpleNamespace
from services.feed_service import _gak_caption
from services.feed_service import _band_sentence, _gak_caption
d = SimpleNamespace(sentences={"0": "쉬어요", "30": "애매", "60": "괜찮아요", "80": "딱 좋아요!"}, windows=[{"from": 18, "to": 24}])
item = SimpleNamespace(definition=d, score=SimpleNamespace(score=83, score_date=date(2026, 10, 7)), trend=[], rank=1)
assert _gak_caption(item) == "딱 좋아요! 하기 좋은 때는 18~24시예요."
item.definition.sentences = {}
assert _band_sentence(d.sentences, 83) == "딱 좋아요!"
assert _gak_caption(item) == "하기 좋은 때는 18~24시예요."
@@ -394,3 +415,19 @@ def test_uv_post_only_when_moderate_or_higher():
assert FeedService._uv_post(None, base, ctx([(12, 2.0), (15, 3.4)])).slides[0].line == "오늘 자외선 지수 보통\n오후 3시 무렵 나가면 선크림·모자 챙겨요"
assert FeedService._uv_post(None, base, ctx([(9, 1.0), (12, 2.5)])) is None
assert FeedService._uv_post(None, base, ctx([])) is None
def test_gak_rows_shows_heaviest_conditions_with_short_values():
from types import SimpleNamespace
from services.feed_service import gak_rows
d = SimpleNamespace(weight_temp=30, weight_rain=25, weight_wind=10, weight_humidity=0, weight_air=15, weight_uv=0, weight_sun=0, weight_view=0, weight_time=20)
notes = {"temp": "체감 18°, 편한 범위 15~25° 안", "rain": "비 확률 20%", "wind": "바람 초속 3.1m", "air": "초미세먼지 16㎍/㎥, 좋음", "time": "수요일"}
item = SimpleNamespace(definition=d, score=SimpleNamespace(notes=notes))
assert [(r.label, r.value) for r in gak_rows(item, 3)] == [("기온", "체감 18°"), ("비", "확률 20%"), ("미세먼지", "좋음")]
# 점수에 안 쓰는 조건은 뒤에 지금 날씨로 채운다
d.weight_wind = 0
assert [r.label for r in gak_rows(item)] == ["기온", "비", "미세먼지", "바람"]
item.score.notes = {**notes, "rain": "비 소식, 내일까지 비 확률 70%"}
assert gak_rows(item)[1].value == "확률 70%"