-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Added REST API tests [**/tasks GET, POST] #4347
Conversation
tests/rest_api/test_0004_tasks.py
Outdated
# TODO: SUPERVISOR DOES NOT SEE CREATED PROJECTS AND CANNOT CREATE TASKS | ||
|
||
# def test_supervisor_can_create_task_in_project_without_ownership(self, users): | ||
# spec = { | ||
# 'name': 'test supervisor can create task in project', | ||
# 'project_id': self._ORG_PROJ_ID, | ||
# } | ||
# self._test_can_create_task_in_project(self._ORG_SUPERVISOR_NOT_OWNER, spec, org=self._ORG) |
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.
@kirill-sizov Please, check the specification
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.
worker3
has privilege worker
, but worker
(as privilege) cannot create a task in this case. To resolve this problem need to change DB (for example change user3
role from supervisor
to worker
) and after that use user3
in these tests. More preferable to make these changes manually not from 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.
@kirill-sizov
We do not use worker3
in this test, the test is for supervisor. And the supervisor does not see any projects in organization.
tests/rest_api/test_0004_tasks.py
Outdated
# [organization] worker (as role) that has one of these ownerships: [Project:owner, Project:assignee] can create task in project | ||
# TODO: A WORKER, ASSIGNED TO A PROJECT STILL CANNOT CREATE TASKS IN THE PROJECT | ||
# def test_worker_with_ownership_can_create_tasks_in_project(self, users): | ||
# spec = { | ||
# 'name': 'test worker with ownerships can create task in project', | ||
# 'project_id': self._ORG_PROJ_ID, | ||
# } | ||
|
||
# worker3 = list(filter(lambda x: x['username'] == 'worker3', users))[0] | ||
|
||
# self._test_cannot_create_task_in_project(worker3['username'], spec, org=self._ORG) | ||
# self._assign_user_to_proj(worker3, self._ORG_PROJ_ID, org=self._ORG) | ||
# self._test_can_create_task_in_project(worker3['username'], spec, org=self._ORG) |
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.
@kirill-sizov Please, check the specification
tests/rest_api/test_0004_tasks.py
Outdated
_ADMIN = 'admin1' | ||
_SAND_PROJ_ID = 1 | ||
_SAND_PROJ_OWNER = 'business1' | ||
_SAND_PROJ_NOT_OWNER = 'business2' | ||
_ORG = 'org2' | ||
_ORG_PROJ_ID = 2 | ||
_ORG_SUPERVISOR_NOT_OWNER = 'user3' | ||
_ORG_WORKER_NO_OWNERSHIP = 'worker3' |
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.
Consider getting rid of hardcoded names and ids in tests. Avoiding hard-coded usernames, identifiers, etc. makes it easier to make new changes to the test database.
Fixture find_user
that allow easy to find needed user with specific organization, role, and privilege:
user0 = find_users(org=1, role='maintainer')[0]['username']
user1 = find_users(privilege='user', org=2)[0]['username']
Here possible solution (not merged yet) for searching needed user with specific ownership for the project
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.
@kirill-sizov Updated. Now the PR depends on your PR #4351
@kirill-sizov Could you please look at the tests? I see there are some snyk issues, but I didn't install any 3rdparty components. |
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, I will merge.
Motivation and context
How has this been tested?
Checklist
develop
branchcvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.