🐛 | Fix tests
All checks were successful
SonarQube Code Quality Scan / SonarQube Scan (push) Successful in 1m44s

This commit is contained in:
2026-06-03 19:05:17 +03:00
parent 93f5239ef7
commit 2870f790bd
4 changed files with 298 additions and 23 deletions

View File

@@ -110,9 +110,31 @@ Tunetti stores its settings in `~/.config/tunetti/config.json`. Here's what you
| [PySide6](https://pypi.org/project/PySide6/) | The graphical interface (Qt6) |
| [pypresence](https://github.com/qwertyquerty/pypresence) | Discord Rich Presence |
## 🧪 Quality checks
## 🧪 Testing
Code quality is analyzed automatically by SonarQube whenever changes are pushed.
Tests use **pytest** with **coverage** and are designed to run both locally and in CI (SonarQube picks up the coverage report automatically).
```bash
# Install test dependencies
pip install -r requirements-dev.txt
# Run all tests
.venv/bin/python -m pytest tests/ -v
# Run with coverage (generates coverage.xml for SonarQube)
.venv/bin/coverage run -m pytest tests/
.venv/bin/coverage xml
```
| Module | Coverage | What's covered |
|---|---|---|
| `music_db.py` | 100% | All DB operations: record, favourites, history, stats, edge cases |
| `config.py` | 87% | Load, save, migrate, volume clamping, get/set settings |
| `discord_rpc.py` | 84% | `_safe_artists` edge cases, DiscordRPC lifecycle, mocked pypresence |
| `player.py` | 32% | Helpers: `_best_thumbnail`, `_build_song_dict`, `_generate_test_wav`, `_stale_files`, `_build_resolved_dict` |
| `gui.py` | 12% | Helpers: `_fmt_ms`, `_artists_str`, `_norm_artists`, `_artists_from_json` |
> The Qt GUI/player classes require a display server and PulseAudio — they can't run in headless CI. Guarded imports (in `player.py` and `gui.py`) ensure pure helper functions are still testable anywhere.
## 📄 License