gcivil-nyu-org / INET-Monday-Fall2023-Team-5

3 stars 5 forks source link

Unit tests #274

Closed ll4407 closed 10 months ago

ll4407 commented 10 months ago

I recently expanded the unit tests in the Accounts application to improve coverage. Here's an overview:

LikeProfileViewTest:

Setup: This class initializes by creating two users and their respective profiles, each starting with three likes remaining.
test_like_profile: This test ensures that when one user likes another, the system correctly creates a Like object and a Match object if there's a mutual like. It also verifies that the likes_remaining count is appropriately updated.
test_already_liked_profile: This test checks the scenario where a user tries to like a profile they've already liked. It validates that the system doesn't create duplicate Like or Match objects and returns the correct error message.

ResetLikesViewTest:

Setup: Similar to the previous class, it sets up two users with profiles. However, their likes_remaining are initially set to different non-zero values for testing the reset functionality.
test_reset_likes: This test creates a staff user to make a POST request, aiming to reset all likes. It checks if the likes are successfully reset to 3 for each user and that all previous likes are cleared.
test_invalid_method: This test, also performed by a staff user, ensures that non-POST requests to the reset likes endpoint correctly return a 400 status code, indicating an invalid method.