feat: pytest + httpx TestClient 인프라 도입 (#18) #23
No reviewers
Labels
No labels
api
bug
chore
collector
decision-needed
docs
enhancement
feature
feedback-loop
frontend
infra
skill
test
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
xhh/financial-data-platform!23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-18-pytest-infra"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
요약
Quality Foundation 마일스톤의 첫 이슈. Sprint 2 본격 기능 전에 TDD 기반을 놓는다.
구성
검증
로컬
uv run pytest→ 3 passed (4.29s). 네트워크/외부 I/O 없음.다음
Closes #18
Sprint 2 본격 기능 전 선행되는 TDD 기반. 이후 모든 신규 엔드포인트/수집기는 테스트 동반 작성을 관례로 한다. ## 구성 ### 디렉토리 - tests/{api,collectors,storage}/ — 도메인별 분리 - tests/conftest.py — 공용 fixture - tests/api/test_health.py — smoke test (3 case) ### conftest 핵심 fixture - test_engine: SQLite in-memory + StaticPool (스레드 공유). create_all 로 스키마 즉시 생성. 실 DB 는 절대 건드리지 않음. - test_session_factory / test_session - client: TestClient + FastAPI dependency_overrides 로 get_database/get_session 을 test DB 로 스위치. API_AUTH_DISABLED=1 자동 설정. ### pyproject.toml [tool.pytest.ini_options] - testpaths=tests, pythonpath=src, asyncio_mode=auto - addopts 에 --strict-markers --strict-config - filterwarnings: 기본 error, DeprecationWarning 만 default (OpenBB 의 Pydantic v2 경고 다수) ### CI (.forgejo/workflows/test.yml) - trigger: pull_request(main) + workflow_dispatch - Runner 라벨 nas 재사용 (uv 는 curl 로 in-step 설치) - uv sync --frozen + uv run pytest ### 의존성 - pytest-asyncio 추가 (dev) - httpx, pytest, pytest-cov 는 기존 있음 ### README - "테스트" 절 추가: uv run pytest / --cov / PR CI 안내 + TDD 관례 명시 ## 검증 로컬 uv run pytest -> 3 passed (/api/health, /api/version, /openapi.json smoke). 외부 I/O 없이 ~4초 내 완료. Closes #18 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>