-
Notifications
You must be signed in to change notification settings - Fork 12
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
RDISCROWD-7409 Locks API #933
Conversation
Pull Request Test Coverage Report for Build 9555263096Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9566672131Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9566671604Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9569244978Details
💛 - Coveralls |
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.
I like the thorough testing and have some comments and questions for you to consider.
test/test_api/test_project_locks.py
Outdated
from test.test_api import TestAPI | ||
|
||
|
||
class TestProjectAPI(TestAPI): |
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.
Should this be TestProjectLocksAPI
?
test/test_api/test_project_locks.py
Outdated
@with_context | ||
def test_project_locks_user_worker(self): | ||
""" Test API should return 401 if user is worker""" | ||
admin = UserFactory.create(admin=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.
admin
is not used in this test...is it necessary for another purpose?
test/test_api/test_project_locks.py
Outdated
@with_context | ||
def test_project_locks_user_subadmin(self): | ||
""" Test API should work if user is subadmin""" | ||
admin = UserFactory.create(admin=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.
like above coment, admin
is also not used
test/test_api/test_project_locks.py
Outdated
|
||
@with_context | ||
def test_project_locks_param_does_not_exist(self): | ||
""" Test API project query when search value does not match""" |
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.
Should this description be Test API project query when search param does not match
?
pybossa/api/project_locks.py
Outdated
|
||
def _select_attributes(self, data): | ||
# Get the project. | ||
project, owner, ps = project_by_shortname(data.get('short_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.
ps
is unused.
pybossa/api/project_locks.py
Outdated
return [] | ||
if (not current_user.is_authenticated or | ||
(not current_user.admin and not current_user.subadmin)): | ||
raise Unauthorized("User not authorized for request") |
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.
Are we okay with subadmins accessing project lock data for all projects? If not, we need revise the implementation and that test case.
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.
Updated logic to verify subadmins are included as owner in project here.
Fixed code review comments in 86953d1. |
Pull Request Test Coverage Report for Build 9571558153Details
💛 - Coveralls |
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.
LGTM, nice work!
/api/locks/{project_id}
Example
Request
HTTP GET
/api/locks/1
Response