# Tests

Ad-hoc test scripts for the Miku Discord Bot. None of these use a formal test framework — they are standalone scripts written during development to validate specific features.

## Test Index

| Script | Type | Requirements | Purpose |
|--------|------|-------------|---------|
| `test_addressing.py` | Unit (self-contained) | None | Tests regex patterns for detecting when Miku is addressed in messages. Replicates logic from `bot/utils/core.py`. |
| `test_pfp_context.py` | Unit (self-contained) | None | Tests regex patterns for detecting profile-picture-related queries. |
| `test_conversation_history.py` | Unit | Built-in mocks | Tests conversation history management logic. |
| `test_error_handler.py` | Unit | Built-in mocks | Tests error handling utilities. |
| `test_evil_moods.py` | Integration | Running Cheshire Cat + Qdrant | Connects via WebSocket and tests all 10 evil mood personalities with sample messages. |
| `test_full_pipeline.py` | Integration | Running Cat + Qdrant | End-to-end test of the memory consolidation system v2. |
| `test_tts_audio.py` | Integration | Run **inside** miku-bot container | Tests the TTS audio streaming pipeline. |
| `test_voice_playback.py` | Integration | Active Discord voice session | Tests audio playback in a live voice channel. |
| `test_websocket.py` | Integration | RVC server at `172.25.0.1:8765` | Tests WebSocket communication with the RVC voice conversion server. |
| `test_rocinante_comparison.py` | Benchmark | Full stack (llama-swap-amd, Cat) | Benchmarks Rocinante-X 12B model through both Normal and Evil Miku scenarios. Outputs to `/tmp/test_rocinante_comparison.log`. |
| `run_rocinante_test.sh` | Shell runner | Docker, full stack | Wrapper script that copies `test_rocinante_comparison.py` into the miku-bot container and runs it. |

## Running Tests

### Self-contained unit tests (no services needed)

```bash
python3 tests/test_addressing.py
python3 tests/test_pfp_context.py
python3 tests/test_conversation_history.py
python3 tests/test_error_handler.py
```

### Integration tests (require running Docker services)

```bash
# Evil moods — needs Cat + Qdrant running
python3 tests/test_evil_moods.py

# Memory consolidation pipeline — needs Cat + Qdrant
python3 tests/test_full_pipeline.py

# TTS — run inside the miku-bot container
docker exec miku-bot python3 /app/tests/test_tts_audio.py

# Voice playback — needs an active voice session
python3 tests/test_voice_playback.py

# WebSocket to RVC — needs RVC server running
python3 tests/test_websocket.py
```

### Benchmark tests

```bash
# Rocinante model comparison (takes a while)
./tests/run_rocinante_test.sh
```
