-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Revoking admin status #181
Conversation
…ser, revoking a self-admin
Please send PRs only to approved issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for sending the PR @sharifa2708 🎉
From what I'm seeing there is some logic missing from the tests because the tests should fail when you don't send an auth header. Feel free to ask any questions regarding my change requests.
db.session.add(self.other_user) | ||
db.session.commit() | ||
|
||
def test_revoke_admin_admin(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_revoke_admin_admin(self): | |
def test_revoke_admin_role(self): |
db.session.commit() | ||
|
||
def test_revoke_admin_admin(self): | ||
if (self.verified_user.is_admin and self.other_user.is_admin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this if statement. you want to test the api, with this values regardless of their values
# self.assertEqual(expected_response, json.loads(actual_response.data)) | ||
|
||
def test_revoke_self_admin(self): | ||
if(self.verified_user.is_admin and self.verified_user==self.other_user): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this if
|
||
|
||
def test_revoke_user(self): | ||
if(self.verified_user.is_admin and self.other_user.is_admin == 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this if statement
def test_revoke_admin_admin(self): | ||
if (self.verified_user.is_admin and self.other_user.is_admin): | ||
expected_response = {'message': 'User admin status was revoked.'} | ||
actual_response = self.client.get('/admin/remove', follow_redirects=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to test api, you have to create header arguments and then use it on the api call. Example: auth_header, otherwise the calls will fail, because the test user isn't authenticated. Do this for the other tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please look into your failing build and fix it.
super(TestListAdminsApi, self).setUp() | ||
|
||
self.verified_user = UserModel( | ||
name=user1['name'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space between variables and operator, follow everywhere, complying to PEP8
self.assertEqual(expected_response, json.loads(actual_response.data)) | ||
|
||
|
||
# def test_revoke_non_user(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No commented code in PRs please.
@sharifa2708 are you still working on this? If you're not, no problem :) We can make the issue available for other contributors. |
Will close this issue and make it available again for lack of updates. |
Description
Added tests for revoking admin status.
Fixes #142
Type of Change:
Code/Quality Assurance Only
How Has This Been Tested?
NA
Checklist:
Code/Quality Assurance Only