This commit introduces a significant number of new unit tests to improve
code coverage and verify the functionality of various components across
the chat, pagos, and principal applications.
Key additions include:
- chat:
- Model tests for ChatRoom (group logic, publicKey, last_message).
- View tests for SMS validation, error handling, and varied context scenarios.
- Form tests for CrearGrupo (validation and dynamic choices).
- Detailed asynchronous tests for ChatConsumer (connection, messaging, encryption, error handling).
- pagos:
- View tests for SMS validation.
- Tests for handling invalid subscription primary keys.
- Improved assertions for payment completion logic.
- Ensured usage of reverse() for URL resolution.
- principal:
- Model tests for Usuario (get_edad, es_premium).
- Detailed tests for the dice_coefficient recommendation logic.
- View tests for SMS validation, piso_encontrado logic, filtering users
with unvalidated SMS, mate actions against users with unvalidated SMS,
and some permission checks for profile details.
- (Note: A second batch of planned tests for principal, including error
handlers, Twilio mocking, and detailed form/statistics tests, could
not be applied due to technical diffing issues.)
Unfortunately, running the full test suite was not possible in the
current environment due to persistent issues with installing the psycopg2
dependency (a sub-dependency of django-heroku) which requires system-level
libraries not available. The implemented tests are therefore submitted
without a full successful test run in this specific environment.
User description
This commit introduces a significant number of new unit tests to improve code coverage and verify the functionality of various components across the chat, pagos, and principal applications.
Key additions include:
chat:
pagos:
principal:
Unfortunately, running the full test suite was not possible in the current environment due to persistent issues with installing the psycopg2 dependency (a sub-dependency of django-heroku) which requires system-level libraries not available. The implemented tests are therefore submitted without a full successful test run in this specific environment.
PR Type
Tests
Description
• Chat app: Complete test suite rewrite expanding from 153 to 538 lines with comprehensive coverage including:
ChatRoom(group()method,public_keygeneration,last_messagedefault)CrearGrupowith dynamic choices and validation rulesChatConsumercovering WebSocket connections, message encryption/decryption, and error handling• Principal app: Added extensive unit tests for:
Usuariomodel methods (get_edad(),es_premium())dice_coefficientfunction testing• Pagos app: Enhanced payment system tests with:
reverse()instead of hardcoded URLs• General improvements: Fixed user creation to use
objects.create_user()for proper password hashing across all test suitesChanges walkthrough 📝
tests.py
Comprehensive unit tests for Usuario model and view functionalityMakeAMate/principal/tests.py
• Added comprehensive test class
TestUsuarioModelfor testingUsuariomodel methods like
get_edad()andes_premium()• Enhanced
recommendation system tests with detailed
dice_coefficientfunctiontesting and improved test data setup
• Expanded mate system tests with
better error handling, SMS validation checks, and comprehensive edge
case coverage
• Added new test class
ViewTestsSMSValidationAndBasicAccessfor testing SMS validationrequirements across views
• Improved existing test classes with proper
use of
reverse()for URL resolution andobjects.create_user()for usercreation
• Added extensive permission and access control tests for
profile detail views
tests.py
Enhanced payment system tests with SMS validationMakeAMate/pagos/tests.py
• Enhanced existing payment tests with proper use of
reverse()for URLresolution instead of hardcoded URLs
• Added SMS validation tests for
payment views to ensure users with unvalidated SMS are redirected
appropriately
• Improved payment completion tests with better
assertions and timezone handling using
timezone.localtime()• Added
test for handling invalid subscription primary keys in paypal view
•
Fixed user creation to use
objects.create_user()for proper passwordhashing
tests.py
Comprehensive test suite expansion for chat functionalityMakeAMate/chat/tests.py
• Completely rewrote and expanded test suite from 153 to 538 lines
with comprehensive coverage
• Added new test classes:
TestChatRoomModel,TestChatForms, andTestChatConsumerfor betterorganization
• Implemented extensive model tests for
ChatRoomincluding
group()method,public_keygeneration, andlast_messagedefault
• Added comprehensive form validation tests for
CrearGrupoform with dynamic choices, min/max selection validation, and name
length validation
• Created detailed asynchronous tests for
ChatConsumercovering WebSocket connections, messageencryption/decryption, error handling, and message history retrieval
•
Enhanced existing view tests with proper URL reversal using
reverse()and added SMS validation checks
• Improved test data setup using
objects.create()methods and added scenarios for users withunvalidated SMS