Skip to content

[Test] 첨삭 모듈 테스트 작성 #88

@chowon442

Description

@chowon442

✨ 기능 설명

첨삭 모듈의 스키마, Generator, Repository, Service, RAG 파이프라인에 대한 유닛 테스트를 작성합니다.

🎯 개발 목적

  • 각 컴포넌트의 정상 동작 및 에지 케이스 검증
  • 리팩토링 시 안전망 확보
  • CI 파이프라인에서 자동 검증

✅ 작업 내용

1. 스키마 테스트 (tests/test_features/test_correction/test_schemas.py)

  • CorrectionLine 생성 및 검증
    • type 값이 "reduce", "keep", "emphasize" 중 하나인지
    • 유효하지 않은 type 값 거부 확인
  • CorrectionField 필드명 Literal 검증 ("description", "contributions", "achievements", "insights")
  • CorrectionOutput 전체 구조 검증
  • CorrectionStatus Enum 값 검증

2. Generator 테스트 (tests/test_features/test_correction/test_generator.py)

  • 검증 로직 테스트 (_validate)
    • 정상 출력 → 에러 없음
    • 라인 번호 범위 초과 → 에러 감지
    • 빈 comment → 에러 감지
    • 빈 overall_summary → 에러 감지
  • LLM 호출 모킹하여 generate() 흐름 테스트
  • 재시도 로직 테스트 (1차 검증 실패 → 2차 성공)

3. Repository 테스트 (tests/test_features/test_correction/test_repository.py)

  • create() → 세션 생성 확인
  • get_by_id() → 조회 및 None 반환 케이스
  • update_status() → 상태 변경 확인
  • update_result() → JSONB 저장/조회
  • update_company_insight() → 기업 분석 저장
  • update_emphasis_points() → 강조 포인트 저장
  • delete() → 삭제 확인
  • save_rag_data() / get_rag_data() → RAG 데이터 CRUD

4. Service 테스트 (tests/test_features/test_correction/test_service.py)

  • create_correction() — 세션 생성 흐름
  • start_rag() — 상태 전이 (NOT_STARTED → DOING_RAG)
  • _run_rag() — RAG 성공/실패 시나리오
  • start_generation() — 상태 전이 (COMPANY_INSIGHT → GENERATING)
  • _run_generation() — 첨삭 생성 성공/실패 시나리오
  • 잘못된 상태에서의 호출 → 에러 발생 확인

5. RAG 테스트 (tests/test_features/test_correction/test_rag.py)

  • RAGPipeline 오케스트레이션 흐름 (LLM 모킹)
  • 키워드 추출 → 검색 → 인사이트 생성 순서 확인
  • 스텁 검색 동작 확인

🔗 관련 이슈

📌 비고

  • tests/test_features/test_portfolio/ 테스트 패턴 참조
  • LLM 호출은 모킹 처리 (unittest.mock.patch 또는 pytest-mock)
  • DB 테스트는 asyncpg 테스트 풀 또는 모킹 사용

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions