Skip to content

Commit 38775d6

Browse files
test: Add comprehensive tests for PromoComment
This commit introduces a new test suite, `PromoCommentsTestCase`, to provide robust test coverage for the promo comments API endpoints. Key functionality covered: - **CRUD Operations**: Full lifecycle testing for creating (POST), retrieving (GET list/detail), updating (PUT), and deleting (DELETE) comments. - **Permissions**: Verifies that users can only modify or delete their own comments (403 Forbidden). - **Error Handling**: Validates correct 404 Not Found responses for invalid requests, such as mismatched promo and comment IDs. - **Data Integrity**: Ensures the `comment_count` on the parent Promo object is correctly updated after comments are created or deleted. - **Listing & Pagination**: Confirms that comments are listed in reverse chronological order and that pagination headers (`X-Total-Count`) are accurate.
1 parent 4d0fef5 commit 38775d6

File tree

2 files changed

+499
-1
lines changed

2 files changed

+499
-1
lines changed

promo_code/user/tests/user/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def tearDown(self):
6868
business.models.Company.objects.all().delete()
6969
business.models.Promo.objects.all().delete()
7070
business.models.PromoCode.objects.all().delete()
71-
user.models.User.objects.all().delete()
71+
user.models.PromoComment.objects.all().delete()
7272
user.models.PromoLike.objects.all().delete()
73+
user.models.User.objects.all().delete()
7374
tb_models.BlacklistedToken.objects.all().delete()
7475
tb_models.OutstandingToken.objects.all().delete()
7576
super().tearDown()

0 commit comments

Comments
 (0)