Skip to content

Feature/cgai increase coverage#19

Merged
Yosoyepa merged 2 commits intodevelopfrom
feature/CGAI-increase-coverage
Dec 1, 2025
Merged

Feature/cgai increase coverage#19
Yosoyepa merged 2 commits intodevelopfrom
feature/CGAI-increase-coverage

Conversation

@Yosoyepa
Copy link
Owner

@Yosoyepa Yosoyepa commented Dec 1, 2025

📋 Descripción

Este PR aumenta la cobertura de tests del backend de 96.25% a 97.46% con 175 tests pasando.

🎯 Cambios Realizados

Nuevos Tests Agregados

Archivo Tests Cobertura Anterior Cobertura Nueva
tests/unit/models/test_code_review.py 4 tests 89% 100%
tests/unit/models/test_finding.py 8 tests 88% 100%
tests/unit/dependencies/test_get_db.py 4 tests 50% 100%

Tests Corregidos

  • test_auth_router.py: Corregidos tests de "missing token" para aceptar 401 o 403 (diferencia entre versiones de FastAPI/Starlette)
  • test_finding.py: Corregido assertion de severity para esperar "HIGH" (mayúsculas) según el enum

📊 Métricas de Cobertura

  • TOTAL 907 23 97%
  • Required test coverage of 75% reached. Tota coverage: 97.46%
  • 175 passed, 6 warnings in 19.17s

✅ Checklist

  • Tests pasan localmente (pytest tests/ --cov=src -v)
  • Tests pasan en GitHub Actions (Linux Python 3.11)
  • Cobertura supera el umbral mínimo (75%)
  • Sin errores de lint
  • Código sigue los principios de diseño del proyecto

🔗 Relacionado

  • Branch: feature/CGAI-increase-coverage
  • Issue: Mejora de cobertura de tests

📝 Notas

Los archivos con cobertura < 100% restantes son:

  • security_agent.py (92%) - Ramas de edge cases complejos
  • code_review_repository.py (89%) - Líneas 74-77 de manejo de errores
  • settings.py (95%) - Línea 57 de configuración condicional
  • observers.py (83%) - Línea 22 de logging
  • schemas/analysis.py (99%) - Línea 80

- Add 12 tests for UserRepository (get_by_id, create, update, delete)
- Add 10 tests for UserEntity (can_analyze, increment_analysis_count)
- Add 9 integration tests for auth endpoints (/login, /me)
- Coverage increased from 92% to 96%
- Add tests for CodeReviewEntity (__repr__, calculate_quality_score)
- Add tests for AgentFindingEntity (penalty, to_dict, __repr__)
- Add tests for get_db dependency (session lifecycle)
- Fix auth router tests to accept 401/403 for missing token
- Fix severity assertion to expect uppercase enum values

Coverage improvements:
- code_review.py: 89% -> 100%
- finding.py: 88% -> 100%
- get_db.py: 50% -> 100%

Total: 175 tests, 97.46% coverage
@Yosoyepa Yosoyepa merged commit 350c505 into develop Dec 1, 2025
7 checks passed
@Yosoyepa Yosoyepa added the good first issue Good for newcomers label Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant