[feat] solution/backend: 일정 프롬프트 — 컨셉을 모델에게 맡기지 않는다

This commit is contained in:
skkim committed 2026-09-11 10:41:00 +09:00
1 parent 25f7e5c0c8
commit 411a4e7d55
3 files changed
+176 -1

No files matched your search

+14 -1
View File
@@ -5,6 +5,13 @@ import os
os.environ.setdefault("APP_ENV", "test")
def pytest_configure(config):
"""순수 단위 테스트(test_itinerary_prompt.py 등)는 DB 없이 실행될 수 있도록 표시한다."""
args = " ".join(config.invocation_params.args)
# test_itinerary_prompt.py 만 실행 중인지 확인
config.SKIP_DB_SETUP = "test_itinerary_prompt.py" in args
import uuid
import pytest
@@ -56,13 +63,19 @@ async def _drop_test_db(*, recreate: bool):
@pytest_asyncio.fixture(scope="session", autouse=True)
async def _test_db_lifecycle():
async def _test_db_lifecycle(request):
"""테스트 세션 동안만 test DB 를 만들고, 끝나면 내린다.
매 세션 '깨끗한 새 DB'로 시작하므로 스키마 낡음(드리프트)이 원천 차단되고, 끝나면 남는 DB 도 없다.
(테이블 구조는 db_engine 의 create_all 이 현재 모델 기준으로 채운다.)
안전가드: 이름에 'test' 있는 DB 만 만들고/지운다(dev DB 보호).
순수 단위 테스트(DB 필요 없음)는 SKIP_DB_SETUP 플래그로 이 fixture 를 건너뛴다.
"""
if getattr(request.config, "SKIP_DB_SETUP", False):
yield
return
assert "test" in main_db_config.name, (
f"비-test DB('{main_db_config.name}') 는 만들거나 지우지 않는다. APP_ENV=test 로 실행하세요."
)