- 화면 전체 스켈레톤, 로딩·완료·실패 사이 레이아웃 고정, 값 없음은 '?' - 행사 사진·출처 표시, 문화정보 API 전시 연결, 행사 30km 거리 기준 - 각 상세 점수 칸 오늘/내일/토/일, 단기예보 밖 주말은 중기예보 예상 점수 - 6각 차트 축 이름을 좋은 방향으로, 계산 근거 문구 정리 - 아이콘 오용·뜻 모를 표시·빈 데이터·포스트 본문 반복 수정 - 미세먼지 별도 포스트, 노을 명소 전국 155곳 거리 기준, 노을 탭 결론 중심 재구성 - 밤 다크 테마·별똥별, 댓글·좋아요 대기·실패 표시 - 주말 전국 랭킹·당일치기 카드, 계절 이야기 사진 수집 - 문서: 포스트 타입별 내용, 각 데이터 정리, TODO 진행 순서
74 lines
2.8 KiB
Python
74 lines
2.8 KiB
Python
from datetime import date, timedelta
|
|
from types import SimpleNamespace
|
|
|
|
from common.enums import RainType, Sky
|
|
from common.utils.kma_time import kst_midnight
|
|
from services.calc.index_calc import Context, DayForecast
|
|
from services.index_service import day_result, slot_days, slot_label
|
|
|
|
REGION = SimpleNamespace(lat=37.56, lon=126.97)
|
|
SAT = date(2026, 10, 10)
|
|
CTX = Context(day=SAT, is_holiday=False, pm25=10, air_label="좋음", moon=0.5, sunset_score=None, wind_warning=False, lookahead_rain_prob=0)
|
|
DEFN = SimpleNamespace(
|
|
weight_temp=40, weight_rain=40, weight_wind=20, weight_humidity=0, weight_air=0, weight_time=0,
|
|
factor_rules={
|
|
"temp": {"type": "range", "lo": 18, "hi": 24}, "rain": {"dir": "dry"}, "wind": {"type": "calm", "ok": 4, "limit": 12},
|
|
"humidity": {"type": "ignore"}, "time": {"type": "fixed", "value": 100},
|
|
},
|
|
zero_rules=[], windows=[{"from": 11, "to": 16}],
|
|
)
|
|
FC = {SAT: DayForecast(temp_min_c=12, temp_max_c=22, rain_prob_am=10, rain_prob_pm=20, sky=Sky.CLEAR)}
|
|
|
|
|
|
def _hourly(day: date) -> dict:
|
|
start = kst_midnight(day)
|
|
return {
|
|
start + timedelta(hours=h): SimpleNamespace(
|
|
forecast_at=start + timedelta(hours=h), feels_c=21, rain_type=RainType.NONE.value, rain_prob=0, wind_ms=1.0, humidity=50, sky=Sky.CLEAR.value,
|
|
)
|
|
for h in range(24)
|
|
}
|
|
|
|
|
|
def _d(day: int) -> date:
|
|
return date(2026, 10, day)
|
|
|
|
|
|
def test_slots_on_weekdays_are_today_tomorrow_sat_sun():
|
|
for today in (5, 6, 7, 8):
|
|
assert slot_days(_d(today)) == [_d(today), _d(today + 1), _d(10), _d(11)]
|
|
|
|
|
|
def test_slots_on_friday_keep_this_sunday_then_next_saturday():
|
|
assert slot_days(_d(9)) == [_d(9), _d(10), _d(11), _d(17)]
|
|
|
|
|
|
def test_slots_on_saturday_and_sunday_move_to_next_weekend():
|
|
assert slot_days(_d(10)) == [_d(10), _d(11), _d(17), _d(18)]
|
|
assert slot_days(_d(11)) == [_d(11), _d(12), _d(17), _d(18)]
|
|
|
|
|
|
def test_slot_labels():
|
|
today = date(2026, 10, 6)
|
|
assert [slot_label(d, today) for d in slot_days(today)] == ["오늘", "내일", "토 10.10", "일 10.11"]
|
|
assert [slot_label(d, _d(9)) for d in slot_days(_d(9))] == ["오늘", "내일", "일 10.11", "토 10.17"]
|
|
|
|
|
|
def test_weekend_in_short_range_uses_hourly_score():
|
|
r = day_result(DEFN, SAT, REGION, _hourly(SAT), FC, CTX, short=False)
|
|
assert r.estimated is False and r.factors["wind"] == 100
|
|
|
|
|
|
def test_weekend_beyond_short_range_uses_mid_forecast_estimate():
|
|
r = day_result(DEFN, SAT, REGION, {}, FC, CTX, short=False)
|
|
assert r.estimated is True and r.factors["wind"] == 70 and r.factors["rain"] == 80
|
|
|
|
|
|
def test_partial_hourly_falls_back_to_estimate():
|
|
partial = {k: v for k, v in _hourly(SAT).items() if k.hour < 13}
|
|
assert day_result(DEFN, SAT, REGION, partial, FC, CTX, short=False).estimated is True
|
|
|
|
|
|
def test_no_mid_forecast_gives_no_score():
|
|
assert day_result(DEFN, SAT, REGION, {}, {}, CTX, short=False) is None
|