deps.get_session 트랜잭션 관리 회귀 테스트 #19

Closed
opened 2026-04-22 02:22:50 +09:00 by xhh · 0 comments
Owner

PR #17 (v0.2.0) 에서 api/deps.pyget_session 이 yield 후 commit 없이 close 만 하던 버그가 발견·수정됨. 누군가 다시 commit 라인을 제거하면 모든 mutation 이 롤백되는 현상이 조용히 재발할 수 있음.

테스트 케이스

tests/api/test_deps.py (또는 test_watchlist.py 내):

  1. POST persist: client.post("/api/watchlist", json=...)client.get("/api/watchlist/{ticker}") 가 동일 레코드 반환.
  2. Exception rollback: 라우터 내에서 의도적으로 IntegrityError 를 유발한 뒤, 같은 세션에서 이전 변경이 롤백됐는지 확인.
  3. Session close: 요청 후 SessionLocal 카운터가 누수 없이 돌아오는지 (선택).

의존

  • #18 (pytest 인프라) 완료 후 작성

완료 기준

  • 위 3개 테스트 통과
  • uv run pytest tests/api/test_watchlist.py::test_post_persists 가 CI 에서 녹색
PR #17 (v0.2.0) 에서 `api/deps.py` 의 `get_session` 이 yield 후 commit 없이 close 만 하던 버그가 발견·수정됨. 누군가 다시 commit 라인을 제거하면 모든 mutation 이 롤백되는 현상이 조용히 재발할 수 있음. ## 테스트 케이스 `tests/api/test_deps.py` (또는 `test_watchlist.py` 내): 1. **POST persist**: `client.post("/api/watchlist", json=...)` → `client.get("/api/watchlist/{ticker}")` 가 동일 레코드 반환. 2. **Exception rollback**: 라우터 내에서 의도적으로 IntegrityError 를 유발한 뒤, 같은 세션에서 이전 변경이 롤백됐는지 확인. 3. **Session close**: 요청 후 SessionLocal 카운터가 누수 없이 돌아오는지 (선택). ## 의존 - #18 (pytest 인프라) 완료 후 작성 ## 완료 기준 - 위 3개 테스트 통과 - `uv run pytest tests/api/test_watchlist.py::test_post_persists` 가 CI 에서 녹색
xhh closed this issue 2026-04-22 02:39:16 +09:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
xhh/financial-data-platform#19
No description provided.