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>
This commit is contained in:
minaChoiandClaude Opus 5.5 committed 2026-10-02 11:32:22 +09:00
1 parent 9cdc0d8fea
commit e134295ce5
135 files changed
+9123

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
from datetime import date
import pytest
from httpx import ASGITransport, AsyncClient
from sqlalchemy import text
from common.database.db_session_manager import DB_SESSION_MNG
from common.enums import PostType
from crud.feed_crud import FeedCRUD
from crud.season_crud import SeasonCRUD
from router.router import app
from services.feed_service import build_feed_day
REGION = "1114000000"
async def _posts(day: date):
_, rows = await DB_SESSION_MNG.execute_lambda(lambda s: s.execute(text(f"SELECT post_type FROM post WHERE feed_date='{day}' ORDER BY position")))
return [r[0] for r in rows]
@pytest.mark.anyio
async def test_build_day_adds_weekend_post_only_from_thursday():
monday, thursday = date(2026, 10, 12), date(2026, 10, 15)
await build_feed_day(monday, FeedCRUD(), SeasonCRUD())
await build_feed_day(thursday, FeedCRUD(), SeasonCRUD())
await build_feed_day(thursday, FeedCRUD(), SeasonCRUD())
assert PostType.WEEK.value not in await _posts(monday)
assert (await _posts(thursday)).count(PostType.WEEK.value) == 1
assert (await _posts(thursday))[0] == PostType.WEATHER.value
@pytest.mark.anyio
async def test_feed_assembles_hero_stories_posts_and_bands(offline):
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
body = (await client.get("/v1/feed", params={"region": REGION})).json()
assert body["result"]["success"] is True
assert body["hero"]["temp_c"] == 20 and len(body["hero"]["top3"]) == 3
assert len(body["stories"]) == 23
weather = next(p for p in body["posts"] if p["post_type"] == PostType.WEATHER.value)
assert [s["kind"] for s in weather["slides"]] == ["hours", "rows", "rows"]
assert len(weather["slides"][0]["hours"]) == 8
assert body["bands"]["events"][0]["name"] == "테스트 축제"