Skip to content
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

Merged
merged 16 commits into from
Feb 25, 2022
Merged

Added REST API tests [**/tasks GET, POST] #4347

merged 16 commits into from
Feb 25, 2022

Conversation

bsekachev
Copy link
Member

Motivation and context

How has this been tested?

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.
  • I have updated the license header for each file (see an example below)
# Copyright (C) 2022 Intel Corporation
#
# SPDX-License-Identifier: MIT

Comment on lines 152 to 159
# 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)
Copy link
Member Author

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

Copy link
Contributor

@sizov-kirill sizov-kirill Feb 17, 2022

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.

Copy link
Member Author

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.

Comment on lines 169 to 181
# [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)
Copy link
Member Author

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

@bsekachev bsekachev changed the title [WIP] Added REST API tests [**/tasks GET, POST] Added REST API tests [**/tasks GET, POST] Feb 15, 2022
Comment on lines 99 to 106
_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'
Copy link
Contributor

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

Copy link
Member Author

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

@bsekachev
Copy link
Member Author

@kirill-sizov Could you please look at the tests? I see there are some snyk issues, but I didn't install any 3rdparty components.

Copy link
Contributor

@nmanovic nmanovic left a 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.

@nmanovic nmanovic merged commit c07a93d into develop Feb 25, 2022
@nmanovic nmanovic deleted the bs/rest_api_tests branch February 25, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants