mentorship-backend
mentorship-backend copied to clipboard
Bugfix: Fix response message when user is not the creator of the mentorship request
Description
Fixes the response message when the user is not the creator of the mentorship request. Fixes #771.
Type of Change:
- Code
Code/Quality Assurance Only
- Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
- Tested through Swagger UI:
- Case 1: the user didn't create the mentorship request

- Case 2: creator deleted the request

- Case 3: mentorship request is not in the
pendingstate
- Case 4: the user was part of the mentorship request, but not the creator

- Unit tests pass (all of them) -> especially observed one that tests this feature
Checklist:
- [x] My PR follows the style guidelines of this project
- [x] I have performed a self-review of my own code or materials
- [x] I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
Code/Quality Assurance Only
- [x] My changes generate no new warnings
- [x] New and existing unit tests pass locally with my changes
Codecov Report
Merging #1012 (cf08b3d) into develop (3fc9582) will decrease coverage by
3.47%. The diff coverage is100.00%.
@@ Coverage Diff @@
## develop #1012 +/- ##
===========================================
- Coverage 96.19% 92.71% -3.48%
===========================================
Files 100 38 -62
Lines 5438 2019 -3419
===========================================
- Hits 5231 1872 -3359
+ Misses 207 147 -60
| Impacted Files | Coverage Δ | |
|---|---|---|
| app/api/resources/mentorship_relation.py | 96.29% <ø> (ø) |
|
| app/messages.py | 100.00% <ø> (ø) |
|
| app/api/dao/mentorship_relation.py | 96.11% <100.00%> (ø) |
|
| app/api/resources/user.py | 89.75% <0.00%> (-0.15%) |
:arrow_down: |
| app/api/models/user.py | 100.00% <0.00%> (ø) |
|
| app/api/resources/admin.py | 88.13% <0.00%> (ø) |
|
| app/api/models/mentorship_relation.py | 100.00% <0.00%> (ø) |
|
| app/schedulers/delete_unverified_users_cron_job.py | 100.00% <0.00%> (ø) |
|
| ...ests/utils/test_get_length_validation_error_msg.py | ||
| ... and 61 more |
@epicadk @vj-codes @devkapilbansal Can you please review this? Thanks :slightly_smiling_face:
So it was just reordering the conditions.
LGTM Thanks @NenadPantelic for this.
P.S. :- Maybe I found some similar happening in
tasksortask_commentstoo. Can you please look into them? Also, amend your message, it should look like:fix: title description
I can take a look :slightly_smiling_face:
@isabelcosta There is already a test that tests this feature. But I can add test that will test the case when the mentorship relation is not in the pending state. Before this change, if the mentorship relation was not in the pending state and the removal request was sent by the non-creator of the request, it would give the The mentorship relation is not in the pending state, now for the same case it gives You cannot delete a mentorship request you did not create, so I think the only thing left is to add the test:
when the user is not the creator and the relation is not in the pending state -> You cannot delete a mentorship request you did not create
@isabelcosta I made the changes.
- added test I mentioned in the comment above
- renamed message constant - the previous var name was not proper, it's not about just uninvolved users, but the user who didn't create the request. Non-creator of the relation request is part of the relation, so involved, but not the creator, so it's forbidden. Please, review it again. Thanks :slightly_smiling_face:
@NenadPantelic any updates on this?
@devkapilbansal Replaced the test implementation with your implementation, thanks for the snippet, you saved me some time :100: