Skip to content

Unit Testing Implementation with pytest #2

@dev-wantap

Description

@dev-wantap

Unit Testing Implementation with pytest

Objective

Implement a comprehensive unit testing framework using pytest to ensure code quality and reliability across all application components.

Tasks

Setup & Configuration

  • pyproject.toml - pytest configuration and development dependencies
  • conftest.py - Common fixtures and test configuration

Unit Tests Implementation

  • tests/unit/routers/test_players.py - Players API endpoint testing
  • tests/unit/routers/test_server.py - Server API endpoint testing with RCON mocking
  • tests/unit/services/test_rcon.py - RCON service logic testing
  • tests/unit/services/test_rabbitmq.py - RabbitMQ service testing with message publishing
  • tests/unit/consumers/test_telegram_sender.py - Telegram consumer message processing
  • tests/unit/consumers/test_discord_sender.py - Discord consumer message processing
  • tests/unit/consumers/test_slack_sender.py - Slack consumer message processing

Test Infrastructure

  • Mock objects for external dependencies (RCON, RabbitMQ, Messenger APIs)
  • Test fixtures for common data structures
  • Async test support configuration

File Structure

├── tests/                      # 테스트 패키지
│   ├── __init__.py
│   ├── conftest.py            # pytest 설정 및 공통 fixture
│   ├── unit/                  # 유닛 테스트
│   │   ├── __init__.py
│   │   ├── routers/
│   │   │   ├── __init__.py
│   │   │   ├── test_players.py  # players API 테스트
│   │   │   └── test_server.py   # server API 테스트 (RCON mock)
│   │   ├── services/
│   │   │   ├── __init__.py
│   │   │   ├── test_rcon.py     # RCON 서비스 테스트
│   │   │   └── test_rabbitmq.py # RabbitMQ 서비스 테스트
│   │   └── consumers/
│   │       ├── __init__.py
│   │       ├── test_telegram_sender.py
│   │       ├── test_discord_sender.py
│   │       └── test_slack_sender.py
│   └── integration/           # 통합 테스트 (선택적)
│       ├── __init__.py
│       └── test_api_integration.py

Success Criteria

  • All API endpoints have comprehensive unit tests
  • External dependencies (RCON, RabbitMQ, Messenger APIs) are properly mocked
  • All tests pass with pytest command
  • Async operations are properly tested
  • Error scenarios are covered with appropriate test cases

Follow-up Tasks

  • Integration tests implementation
  • GitHub Actions CI workflow setup
  • Coverage reporting integration
  • Performance testing implementation

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions