Skip to content

[CHORE] 모듈별 테스트 코드 작성 #21

Description

@KIMB0B

작업 내용

모듈별 테스트 코드 작성 후 CI 정상 동작을 확인한다.

테스트 코드 패턴

  • test_repository.py — 실제 DB 세션(session 픽스처)으로 쿼리 동작 검증
  • test_service.py — 세션/레포지토리를 mock으로 대체해 비즈니스 로직만 검증
  • test_router.py — TestClient + dependency_overrides로 서비스를 mock 처리해 API 계약 검증

작업 목록

  • notice 모듈 테스트 (repository/service/router)
  • project 모듈 테스트 (초대/멤버/리더위임 로직 포함)
  • notification 모듈 테스트 (repository/service/router + events.py, outbox_relay.py, consumer.py)
  • chat 모듈 테스트 (repository/service/router + ConnectionManager)
  • member 모듈 테스트
  • work 모듈 테스트
  • favorite 모듈 테스트

(순서는 상관 없음 - 편한거 먼저)

수용 기준

  • 모듈별로 3분할 구조(repository/service/router) 유지
  • pytest -q 로컬/CI 모두 통과

참고 사항

  • CI에 Redis 서비스가 없음 (.github/workflows/ci.yml에 postgres service만 있고 redis는 없음) → notification/chat처럼 redis_client를 쓰는 모듈 테스트를 추가하려면 CI 워크플로에 Redis 서비스 블록 추가가 선행되어야 함
  • tests/conftest.py에 지금은 skill 전용 픽스처(skill_repo, skill_factory 등)가 전부 최상위에 박혀있음 → 모듈이 늘어나면 이 파일이 계속 커지므로, tests/notice/conftest.py처럼 모듈별 conftest로 분리하는 것을 이 작업과 함께 진행 권장 (공통 픽스처만 최상위 conftest.py에 남기기)
  • outbox_relay.py/consumer.py처럼 무한루프 백그라운드 태스크는 통째로 테스트하기보다 _dispatch_once()/_handle_message()처럼 한 번 실행 단위 함수를 직접 호출해서 검증하는 방식 권장

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions