mentorship-backend icon indicating copy to clipboard operation
mentorship-backend copied to clipboard

Bugfix: Fix response message when user is not the creator of the mentorship request

Open NenadPantelic opened this issue 4 years ago • 7 comments

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?

  1. Tested through Swagger UI:
  • Case 1: the user didn't create the mentorship request image
  • Case 2: creator deleted the request image
  • Case 3: mentorship request is not in the pending state image
  • Case 4: the user was part of the mentorship request, but not the creator image
  1. 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

NenadPantelic avatar Feb 22 '21 17:02 NenadPantelic

Codecov Report

Merging #1012 (cf08b3d) into develop (3fc9582) will decrease coverage by 3.47%. The diff coverage is 100.00%.

Impacted file tree graph

@@             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

codecov[bot] avatar Feb 22 '21 17:02 codecov[bot]

@epicadk @vj-codes @devkapilbansal Can you please review this? Thanks :slightly_smiling_face:

NenadPantelic avatar Feb 22 '21 17:02 NenadPantelic

So it was just reordering the conditions.

LGTM Thanks @NenadPantelic for this.

P.S. :- Maybe I found some similar happening in tasks or task_comments too. 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:

NenadPantelic avatar Feb 22 '21 21:02 NenadPantelic

@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

NenadPantelic avatar Feb 23 '21 10:02 NenadPantelic

@isabelcosta I made the changes.

  1. added test I mentioned in the comment above
  2. 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 avatar Feb 23 '21 11:02 NenadPantelic

@NenadPantelic any updates on this?

vj-codes avatar Apr 11 '21 07:04 vj-codes

@devkapilbansal Replaced the test implementation with your implementation, thanks for the snippet, you saved me some time :100:

NenadPantelic avatar Apr 23 '21 16:04 NenadPantelic