fix: 같은 축제가 다른 출처로 이미 있으면 넣지 않기 (이름 같고 기간 겹침)

This commit is contained in:
minaChoi committed 2026-10-08 13:29:20 +09:00
1 parent 0436971cf1
commit b889f69135
3 files changed
+45 -2

No files matched your search

+22
View File
@@ -59,3 +59,25 @@ async def test_seoul_failure_keeps_other_sources(monkeypatch):
monkeypatch.setattr(week_service, "fetch_seoul_festivals", broken)
assert await _seoul(None, "11", date(2026, 10, 8), []) == []
def _row(source_id, name, start, end, sido="11"):
return {"source_id": source_id, "sido_code": sido, "name": name, "place_name": "", "start_date": start, "end_date": end,
"is_confirmed": True, "source_url": None, "image_url": None, "lat": None, "lon": None, "kind": 1, "icon": "fireworks"}
@pytest.mark.anyio
async def test_drop_known_skips_same_festival_from_another_source():
from common.database.db_session_manager import DB_SESSION_MNG
from crud.week_crud import WeekCRUD
from services.week_service import drop_known
tour = _row("9001", "경복궁 별빛야행", date(2026, 10, 1), date(2026, 10, 24))
await DB_SESSION_MNG.execute_lambda_run([lambda s: WeekCRUD().upsert_events(s, [tour])])
rows = [
_row("popga:1", "2026 경복궁 별빛야행", date(2026, 10, 8), date(2026, 10, 10)),
_row("popga:2", "경복궁 별빛야행", date(2026, 11, 1), date(2026, 11, 2)),
_row("popga:3", "경복궁 별빛야행", date(2026, 10, 8), date(2026, 10, 10), sido="41"),
_row("9001", "경복궁 별빛야행", date(2026, 10, 1), date(2026, 10, 25)),
]
assert [r["source_id"] for r in await drop_known(rows)] == ["popga:2", "popga:3", "9001"]