fix: 출시 전 QA 버그 3건 — 주말 플랜 500, 광주·전남 행사 0건, 미세먼지 갱신 멈춤

- 주말 플랜: '14시~' 같은 시간 라벨에서 정렬이 멈춰 피드 전체가 500 (광산구·울릉군)
- 광주·전남: 구 코드는 12인데 행사는 29·46으로 저장돼 27개 구에서 행사를 못 찾음
- 미세먼지: 에어코리아 전국 조회가 15~20초 걸려 8초 한도에 매번 걸림 → 45초
This commit is contained in:
minaChoi committed 2026-10-08 13:58:06 +09:00
1 parent 5734b57758
commit 1fa0695c84
7 files changed
+60 -12

No files matched your search

+15 -1
View File
@@ -5,7 +5,8 @@ import httpx
import pytest
from config.settings import settings
from services.external import data_go_kr, guard, open_meteo
from services.external import airkorea, data_go_kr, guard, open_meteo
from services.external.airkorea import fetch_realtime
from services.external.data_go_kr import DataGoKrRequestFailed, get_body
from services.external.open_meteo import OpenMeteoRequestFailed, fetch_clouds
@@ -93,3 +94,16 @@ async def test_open_meteo_down_is_skipped(monkeypatch):
with pytest.raises(OpenMeteoRequestFailed):
await fetch_clouds(client, [(37.5, 127.0)])
assert len(calls) == 1
@pytest.mark.anyio
async def test_airkorea_nationwide_call_waits_past_default_budget(fast, monkeypatch):
"""전국 미세먼지 조회는 15~20초 걸려 기본 한도로는 늘 실패한다."""
monkeypatch.setattr(airkorea, "BUDGET_SEC", 2.0)
async def slow(req: httpx.Request) -> httpx.Response:
await asyncio.sleep(0.5)
return httpx.Response(200, json={"response": {"header": {"resultCode": "00"}, "body": {"items": [{"stationName": "x"}], "totalCount": 1}}})
async with _client(slow) as client:
assert await fetch_realtime(client) == [{"stationName": "x"}]
+16
View File
@@ -169,6 +169,22 @@ async def test_events_pick_within_30km_across_sido(fakes, monkeypatch):
assert {e["name"] for e in body["events"]} == {"잠실 축제", "좌표 없는 경기 축제"}
@pytest.mark.anyio
async def test_gwangju_jeonnam_region_finds_events_saved_as_29_and_46(fakes, monkeypatch):
"""구 코드는 광주·전남이 12로 묶이지만 행사는 광주 29 · 전남 46으로 저장된다. 광산구에서 둘 다 보여야 한다."""
today = now_kst().date()
span = {"eventstartdate": (today + timedelta(days=1)).strftime("%Y%m%d"), "eventenddate": (today + timedelta(days=3)).strftime("%Y%m%d")}
by_sido = {
"29": [{"contentid": "29", "title": "광주 축제", "addr1": "광주 광산구", "mapy": "35.1396", "mapx": "126.7937", **span}],
"46": [{"contentid": "46", "title": "좌표 없는 전남 축제", "addr1": "전남", **span}],
}
monkeypatch.setattr(week_service, "fetch_festivals", lambda client, sido, since: _async(by_sido.get(sido, [])))
await _collect("29", "46")
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
body = (await client.get("/v1/week/event/list", params={"region": "1233000000"})).json()
assert {e["name"] for e in body["events"]} == {"광주 축제", "좌표 없는 전남 축제"}
@pytest.mark.anyio
async def test_places_put_indoor_first_on_rainy_day(fakes):
rainy_day = (now_kst().date() + timedelta(days=2)).isoformat()
+5
View File
@@ -55,6 +55,11 @@ def test_afternoon_rain_moves_outdoor_time_before_it():
assert card.line.startswith("비 오는 토요일")
def test_morning_rain_then_outdoor_after_it_ends():
card = day_plan(_day(SAT, rainy=True, rain_hours=(9, 14), prob=60), None, [], None)
assert [s.time for s in card.steps] == ["9~14시", "14시~"]
def test_saturday_ignores_ending_hook_and_sunday_skips_saturday_events():
near = _event("가까운 축제", SAT, SUN, 3.0)
ends_sat = _event("토요일 끝", SAT, SAT, 50.0)