Mentorship-backend: Add tests for Revoking admin role API

Created on 30 Aug 2018  路  26Comments  路  Source: anitab-org/mentorship-backend

Description

As a developer,
I need have tests for revoking an admin role feature,
so that I can have the feature coverage and make sure it's working properly.

Have a test function for each of this cases:

  • Revoking a user which is an admin, when the current user is an admin -> should receive a success message, and remove the admin status from the revoked user
  • Revoking a user which is not an admin -> should receive a message indicating the user is not an admin
  • Revoking a user as an admin, when the current user is not an admin -> should receive an error message
  • Revoking a non-existent user -> should receive error message
  • Revoke self the admin role, should only work if the user is not the only user
  • Try using the API without sending authentication token -> should receive an error message

You can test your tests running:

python -m unittest discover tests

Acceptance Criteria

Update [Required]

  • [ ] Create a test file, on tests/admin folder, with test cases for revvoking an admin role API (you can follow this test case example https://github.com/systers/mentorship-backend/blob/develop/tests/users/test_api_list_users.py)

Definition of Done

  • [ ] All of the required items are completed.
  • [x] Approval by 1 mentor.

Estimation

4 hours

Coding First Timers Only Available Testing

All 26 comments

@systers/maintainers-mentorship-backend need approval on this if you agree.

The author of the issue cannot approve the issue.

@isabelcosta, can I please claim this issue?

Sure @madzzie :) If you need any clarification about it just ask

@madzzie any updates on your work?

can i take up this issue ? if no assignees already there?

Yes @sidharthskumar you can take on this issue

@sidharthskumar do you have any updates on this?

@sidharthskumar I will make this available again for others to work on this.

@isabelcosta I would like to take up this issue.

@sharifa2708 great! Go ahead!

I am working on this. I will be needing a bit more time.

No problem at all @sharifa2708 , thank you for updating us through the issue.
That's what we need from contributors when they need more time :)

For documentation purposes, this is a message I wrote for a contributor on slack about this issue:

If you take a look at the issue description you have an example of API testing you can follow. Basically, you have to understand what revoke and admin role means.

Basic rules: you can only revoke an admin if you are an admin, you cannot revoke your admin status if you're the only admin. Unfortunately, we don't have yet in code documentation, but we'll have in the future. You'll have to study the code to understand how it works the business logic. After you understand it, create tests to test the API, having in consideration the business logic (basic rules) I told you about. I left an example of API tests in the Issue description, so you can understand how tests are made in this project. Also, you already have the minimum test cases we need for the feature.

TL;DR; study the code, create API tests that test the test cases I wrote in the issue, and follow the example present in the issue (file: test_api_list_users.py)

@sharifa2708 are you still working on this? if you need any help just ping me here or no #mentorship-system channel on slack.

Yes @isabelcosta I was stuck with this issue. I had been working on this issue and wasn't getting it through so I left it for a bit. I am working on it. If I couldn't solve it for some more time by my own I will surely take your help.

@sys-bot approve

Is this project available?

@efitzpatrick yes it is available :) Let me know if you wish to work on that, so that I can remove the "Status: Available" label.

Is this still open and assignable?

Hello, is this issue still open? I can work on it , it will be my first contribution to an open source project.

Hi @StergiosSozos, would you still like to work on this issue?

Hi @StergiosSozos, would you still like to work on this issue?

No, I wasn't assigned to this issue, I am working on a different issue. You can ask @isabelcosta to be assigned

Hi @meenakshi-dhanani
Please assign me this issue as discussed with you in Zulip. Thank You.

Thank you @sidvenu :)

@vj-codes please make this issue available again

Was this page helpful?
0 / 5 - 0 ratings