- 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>
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
import pytest
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from router.router import app
|
|
|
|
|
|
async def _get(path: str, **params):
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
return (await client.get(path, params=params)).json()
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_region_list_has_all_256_districts():
|
|
body = await _get("/v1/region/list")
|
|
assert body["result"]["success"] is True
|
|
assert len(body["regions"]) == 256
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_region_search_by_name():
|
|
body = await _get("/v1/region/list", q="마포")
|
|
assert [r["name"] for r in body["regions"]] == ["서울 마포구"]
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_nearest_from_mangwon_park_is_mapo():
|
|
body = await _get("/v1/region/nearest", lat=37.5555, lon=126.8950)
|
|
assert body["region"]["name"] == "서울 마포구"
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_nearest_rejects_point_outside_korea():
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
res = await client.get("/v1/region/nearest", params={"lat": 10, "lon": 127})
|
|
assert res.status_code == 422
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_enum_query_param_accepts_numeric_string():
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
res = await client.get("/v1/season/article/list", params={"category": "2"})
|
|
assert res.status_code == 200 and all(a["category"] == 2 for a in res.json()["articles"])
|