# AudiOhm - README des Tests ## 📁 Structure des Tests ``` /opt/audiOhm/backend/ ├── test_new_features.py # Suite de tests automatisĂ©s backend ├── fix_bug_1.sh # Script de correction du Bug #1 ├── TEST_REPORT.md # Rapport dĂ©taillĂ© des tests ├── TEST_SUMMARY.md # RĂ©sumĂ© exĂ©cutif ├── FRONTEND_TEST_GUIDE.md # Guide de test manuel frontend └── README_TESTS.md # Ce fichier ``` --- ## 🚀 Utilisation Rapide ### 1. Lancer les tests backend ```bash cd /opt/audiOhm/backend python3 test_new_features.py ``` **RĂ©sultat attendu:** ``` Total Tests: 24 Passed: 20 Failed: 4 Success Rate: 83.3% ``` ### 2. Corriger le Bug #1 ```bash cd /opt/audiOhm/backend sudo ./fix_bug_1.sh ``` ### 3. Relancer les tests aprĂšs correction ```bash python3 test_new_features.py ``` **RĂ©sultat attendu aprĂšs correction:** ``` Total Tests: 24 Passed: 23 Failed: 1 Success Rate: 95.8% ``` --- ## 📊 CatĂ©gories de Tests ### Backend API (AutomatisĂ©s) 1. **Authentification** ✅ - Login - Get current user - Token refresh 2. **Recherche Musicale** ✅ - Search tracks - Create from YouTube 3. **BibliothĂšque - Liked Tracks** ⚠ - Like track (❌ Bug #1) - Get liked tracks (❌ Bug #1) - Check track liked ✅ - Unlike track ✅ 4. **BibliothĂšque - Historique** ⚠ - Add to history (❌ Bug #1) - Get listening history ✅ - Get recently played ✅ - Get most played (❌ Bug #1) - Get library stats ✅ - Clear history ✅ 5. **Playlists** ✅ - Create playlist ✅ - Get playlists ✅ - Get playlist details ✅ - Add tracks ✅ - Update playlist ✅ - Remove track ✅ - Delete playlist ✅ ### Frontend (Manuels) Voir `FRONTEND_TEST_GUIDE.md` pour les instructions dĂ©taillĂ©es. --- ## 🐛 Bugs Connus ### Bug #1: Type Mismatch `listening_history.completed` **SymptĂŽme:** ``` 500 Internal Server Error column "completed" is of type integer but expression is of type boolean ``` **Impact:** - Ajout d'historique impossible - Statistiques "most played" ne fonctionnent pas **Solution:** ```bash sudo ./fix_bug_1.sh ``` --- ## 📖 Documentation ### Rapport DĂ©taillĂ© **Fichier:** `TEST_REPORT.md` - Analyse complĂšte de chaque test - Stack traces des erreurs - Solutions dĂ©taillĂ©es - Commandes de reproduction ### RĂ©sumĂ© ExĂ©cutif **Fichier:** `TEST_SUMMARY.md` - Vue d'ensemble des rĂ©sultats - MĂ©triques de qualitĂ© - Roadmap de correction - Recommandations ### Guide Frontend **Fichier:** `FRONTEND_TEST_GUIDE.md` - 10 catĂ©gories de tests manuels - Instructions pas-Ă -pas - Checklists de validation - Outils de dĂ©veloppement --- ## 🔧 Personnalisation des Tests ### Modifier les identifiants de test Dans `test_new_features.py`, lignes 774-775: ```python json={ "email": "admin@example.com", "password": "admin123" } ``` ### Modifier la requĂȘte de recherche Ligne 783: ```python params={"q": "queen bohemian rhapsody", "type": "track", "limit": 5}, ``` ### Ajouter de nouveaux tests 1. CrĂ©er une nouvelle mĂ©thode dans la classe `AudiOhmTester`: ```python async def test_my_new_feature(self, result: TestResult) -> bool: """Test my new feature.""" self.print_test("My New Feature") try: # Your test code here response = await self.client.get( f"{self.base_url}/api/v1/my-endpoint", headers=self.get_headers() ) if response.status_code == 200: self.print_success("Feature works!") result.add_pass() return True else: self.print_error(f"Feature failed: {response.status_code}") result.add_fail("My New Feature", f"Status: {response.status_code}") return False except Exception as e: self.print_error(f"Error: {str(e)}") result.add_fail("My New Feature", str(e)) return False ``` 2. Ajouter le test dans `run_all_tests()`: ```python # Dans la mĂ©thode run_all_tests() self.print_header("X. MY NEW FEATURE") await self.test_my_new_feature(result) ``` --- ## 📈 IntĂ©gration CI/CD ### GitHub Actions Example ```yaml name: Run AudiOhm Tests on: [push, pull_request] jobs: test: runs-on: ubuntu-latest services: postgres: image: postgres:15 env: POSTGRES_DB: audiOhm_test POSTGRES_USER: audiOhm POSTGRES_PASSWORD: test123 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install dependencies run: | pip install -r requirements.txt - name: Run tests run: | python3 test_new_features.py env: DATABASE_URL: postgresql://audiOhm:test123@localhost:5432/audiOhm_test - name: Upload test results if: always() uses: actions/upload-artifact@v3 with: name: test-results path: test_results.json ``` --- ## đŸ€ Contribution Pour ajouter des tests: 1. Fork le projet 2. CrĂ©er une branche `feature/new-tests` 3. Ajouter vos tests dans `test_new_features.py` 4. Mettre Ă  jour ce README 5. Submit une PR --- ## 📞 Support Pour toute question sur les tests: 1. VĂ©rifier d'abord `TEST_REPORT.md` (problĂšmes connus) 2. Consulter `FRONTEND_TEST_GUIDE.md` (tests UI) 3. Regarder les logs dans la console --- ## 📝 Changelog ### v1.0.0 (2025-01-19) - Suite initiale de 24 tests backend - Script de correction Bug #1 - Documentation complĂšte (3 fichiers) - Taux de rĂ©ussite: 83.3% ### Prochaine version (v1.1.0) - [ ] Tests E2E avec WebDriver - [ ] Tests de performance - [ ] Tests de sĂ©curitĂ© - [ ] Couverture frontend --- **Mainteneur:** QA Expert **DerniĂšre mise Ă  jour:** 2025-01-19 **Version:** 1.0.0