You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
805 B
Python
23 lines
805 B
Python
# backend/app/routers/_test.py (테스트 전용 — 운영 빌드에서 가드)
|
|
import os
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
from sqlmodel import Session, SQLModel
|
|
|
|
from app.db import engine, get_session
|
|
from app.seed import run_seed
|
|
|
|
router = APIRouter() # prefix 없음. main.py 에서 prefix="/api" 등록.
|
|
|
|
|
|
@router.post("/_test/reset")
|
|
def reset_seed(session: Session = Depends(get_session)):
|
|
"""시드를 초기 상태로 되돌린다. ARI_ALLOW_TEST_RESET=1 일 때만 동작(운영 403)."""
|
|
if os.getenv("ARI_ALLOW_TEST_RESET") != "1":
|
|
raise HTTPException(403, "test reset disabled")
|
|
SQLModel.metadata.drop_all(engine)
|
|
SQLModel.metadata.create_all(engine)
|
|
run_seed(session=session, reset=True)
|
|
session.commit()
|
|
return {"status": "reset"}
|