Files
o2o-weather/backend/tests/test_weather_calc.py
minaChoiandClaude Opus 5.5 e134295ce5 feat: 날씨각 백엔드 API (날씨·노을·지수·주말·계절·피드·로그인·반응)
- FastAPI + PostgreSQL + Redis, web·worker 분리, compose 에 backend·worker·postgres·redis 추가
- 기상청 단기·초단기·중기·특보, 에어코리아, Open-Meteo, TourAPI, 특일정보 연동 (첫 조회 때 받고 캐시)
- 매일 03:00 worker 가 전국 공통 피드 칸을 정하고 지난 데이터를 정리
- 시드: 시군구 256곳, 지수 23개, 노을 대표 지점·명소, 데이트 명소, 읽을거리
- pytest 66개 (테스트 전용 DB·Redis 사용)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 11:32:22 +09:00

35 lines
1.0 KiB
Python

from datetime import date, datetime
from common.utils.kma_time import KST
from services.calc.sun import sun_times
from services.calc.weather_calc import discomfort_index, feels_like_c
def test_discomfort_index_21c_68pct():
assert discomfort_index(21, 68) == 68
def test_feels_like_winter_uses_wind_chill():
assert feels_like_c(0, 50, 5.0, 1) < -4
def test_feels_like_winter_no_wind_is_same_temp():
assert feels_like_c(5, 50, 0.5, 12) == 5
def test_feels_like_summer_humid_is_hotter():
assert feels_like_c(30, 80, 2.0, 8) > feels_like_c(30, 30, 2.0, 8)
def _minutes_kst(dt: datetime) -> int:
k = dt.astimezone(KST)
return k.hour * 60 + k.minute
def test_sun_times_seoul_matches_open_meteo_within_3_minutes():
t = sun_times(date(2026, 10, 1), 37.55, 126.875)
assert abs(_minutes_kst(t.sunrise_at) - (6 * 60 + 27)) <= 3
assert abs(_minutes_kst(t.sunset_at) - (18 * 60 + 16)) <= 3
assert 20 <= (t.dusk_end_at - t.sunset_at).total_seconds() / 60 <= 35
assert 255 <= t.sunset_azimuth <= 268