# Test Suite Coverage This document tracks the test coverage for Senator Sperma bot. ## Running Tests ```bash pytest tests/ -v ``` ## Coverage by Cog | Cog | Test File | Tests | Coverage | |-----|-----------|-------|----------| | **say.py** | test_say.py | 3 | Basic command execution, empty text, long text | | **web.py** | test_web.py | 3 | Success, no results, HTTP error | | **qr.py** | test_qr.py | 4 | Generate, empty text, decode unavailable, download failure | | **math_commands.py** | test_math_commands.py | 3 | Valid expression, invalid expression, process error | | **ai.py** | test_ai.py | 3 | Success, empty choices, no choices key | | **downloader.py** | test_downloader.py | 5 | File success, URL success, error, message with/without URL | | **search.py** | test_search.py | 5 | Success, no cache, file not found, empty filename, autocomplete | | **tts.py** | test_tts.py | 3 | File output, voice output not in channel, error handling | | **trigger.py** | test_trigger.py | 5 | Create, add, add not found, delete, help | | **compression.py** | test_compression_conversion.py | 4 | Filetype detection, get compression commands | | **conversion.py** | test_compression_conversion.py | 5 | Build conversion commands, cleanup | | **plot.py** | test_plot.py | 6 | Parse expression, is implicit, parse implicit, command execution | | **vclogs.py** | test_vclogs.py | 7 | Format duration, load/save activity, state change handlers | | **voice.py** | test_voice.py | 5 | Get manager, join channel, get status, stop | | **music/join.py** | test_music_join.py | 1 | Join command success | | **music/stop.py** | test_music_join.py | 1 | Stop command success | | **music/play_commands.py** | test_music_play.py | 4 | Search embed, validation errors | | **music/loop.py** | test_music_play.py | 2 | Is looping, toggle | | **music/audio_playback.py** | test_music_audio.py | 8 | Validate voice, prepare source, cleanup | | **assistant.py** | test_assistant.py | 4 | Keyword, on_message filtering, mentions | ## Test Structure ``` tests/ ├── conftest.py # Shared fixtures and mock classes ├── cogs/ │ ├── test_say.py │ ├── test_web.py │ ├── test_qr.py │ ├── test_math_commands.py │ ├── test_ai.py │ ├── test_downloader.py │ ├── test_search.py │ ├── test_tts.py │ ├── test_trigger.py │ ├── test_compression_conversion.py │ ├── test_plot.py │ ├── test_vclogs.py │ ├── test_voice.py │ ├── test_music_join.py │ ├── test_music_play.py │ ├── test_music_audio.py │ └── test_assistant.py └── README.md # This file ``` ## Mock Classes The test suite uses custom mock classes defined in `conftest.py`: - `MockUser` - Simulates Discord user - `MockChannel` / `MockTextChannel` / `MockVoiceChannel` - Simulates Discord channels - `MockGuild` - Simulates Discord guild - `MockMessage` - Simulates Discord message - `MockInteraction` - Simulates Discord interaction - `MockApplicationContext` - Simulates slash command context ## Test Categories 1. **Unit tests** - Test individual functions and methods 2. **Integration tests** - Test command execution with mocked dependencies 3. **Error handling tests** - Test error conditions and edge cases ## Notes - External services (OpenAI, yt-dlp, ffmpeg) are mocked - Database operations in trigger.py are mocked - File system operations are mocked where needed - Some tests may require specific environment variables to be set (mocked)