From f3426520c20b666357d95077e49829f917381bd2 Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 15:24:52 -0500 Subject: [PATCH 01/10] Bug report template: Bug report, UI task, Back End --- .github/ISSUE_TEMPLATE/back-end.md | 29 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 38 ++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/ui-task.md | 26 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/back-end.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/ui-task.md diff --git a/.github/ISSUE_TEMPLATE/back-end.md b/.github/ISSUE_TEMPLATE/back-end.md new file mode 100644 index 00000000..ffaa7b17 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/back-end.md @@ -0,0 +1,29 @@ +--- +name: Back end +about: new tasks of Back-end +title: BACK-END +labels: '' +assignees: '' + +--- + +**Purpose** +A clear and concise description of this new task or feature + +** Purpose** +A clear and concise description of what you want to happen. + +**Optional diagrams** +Optional designs of diagrams. + +**Criteria of acceptance** +List the parameters that the task must meet to be approved. +- parameter one +- parameter two +- ... + +**Scope** +Defined scope of this task, for example business logic, the recommendation is to create a meeting with more than one person to define this scope. + +**Note** +Information adicional, por example links of documentation to work in xz task. diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..7d6855a2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: BUG +labels: low +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md new file mode 100644 index 00000000..74876001 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/ui-task.md @@ -0,0 +1,26 @@ +--- +name: UI task +about: new tasks of UI +title: UI TASK +labels: '' +assignees: '' + +--- + +** Purpose** +A clear and concise description of this new task or feature + +** Purpose** +A clear and concise description of what you want to happen. + +**Design link** +Links of design in invisionApp, mockflow, zeiplin, etc + +**Criteria of acceptance** +List the parameters that the task must meet to be approved. +- parameter one +- parameter two +- ... + +**Note** +Information adicional, por example links of documentation to work in xz task. From 76728f491820aa95d1f45ddb2565bd05ed34648f Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 15:35:24 -0500 Subject: [PATCH 02/10] fix: issue templates --- .github/ISSUE_TEMPLATE/back-end.md | 2 +- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/ui-task.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/back-end.md b/.github/ISSUE_TEMPLATE/back-end.md index ffaa7b17..9b397835 100644 --- a/.github/ISSUE_TEMPLATE/back-end.md +++ b/.github/ISSUE_TEMPLATE/back-end.md @@ -2,7 +2,7 @@ name: Back end about: new tasks of Back-end title: BACK-END -labels: '' +labels: mvp, nice-to-have, tech-debt, enhancement assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7d6855a2..ea197258 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: BUG -labels: low +labels: low, medium, high assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md index 74876001..2d98bf34 100644 --- a/.github/ISSUE_TEMPLATE/ui-task.md +++ b/.github/ISSUE_TEMPLATE/ui-task.md @@ -2,7 +2,7 @@ name: UI task about: new tasks of UI title: UI TASK -labels: '' +labels: mvp, nice-to-have, tech-debt, enhancement assignees: '' --- From 55b73bb9cc546306f2c81785581fd593d71172fe Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 15:40:57 -0500 Subject: [PATCH 03/10] fix: issue templates --- .github/ISSUE_TEMPLATE/back-end.md | 4 ++-- .github/ISSUE_TEMPLATE/ui-task.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/back-end.md b/.github/ISSUE_TEMPLATE/back-end.md index 9b397835..e4aaa071 100644 --- a/.github/ISSUE_TEMPLATE/back-end.md +++ b/.github/ISSUE_TEMPLATE/back-end.md @@ -14,7 +14,7 @@ A clear and concise description of this new task or feature A clear and concise description of what you want to happen. **Optional diagrams** -Optional designs of diagrams. +Optional designs of diagrams. **Criteria of acceptance** List the parameters that the task must meet to be approved. @@ -26,4 +26,4 @@ List the parameters that the task must meet to be approved. Defined scope of this task, for example business logic, the recommendation is to create a meeting with more than one person to define this scope. **Note** -Information adicional, por example links of documentation to work in xz task. +Information adicional, for example links of documentation to work in xz task. diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md index 2d98bf34..2f42a594 100644 --- a/.github/ISSUE_TEMPLATE/ui-task.md +++ b/.github/ISSUE_TEMPLATE/ui-task.md @@ -23,4 +23,4 @@ List the parameters that the task must meet to be approved. - ... **Note** -Information adicional, por example links of documentation to work in xz task. +Information adicional, for example links of documentation to work in xz task. From 0be1370d81f4dcec739ed2bf8f3eff25640af36b Mon Sep 17 00:00:00 2001 From: Sandro Castillo Date: Fri, 13 Nov 2020 16:26:00 -0500 Subject: [PATCH 04/10] fix: delete ui-task template --- .github/ISSUE_TEMPLATE/ui-task.md | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/ui-task.md diff --git a/.github/ISSUE_TEMPLATE/ui-task.md b/.github/ISSUE_TEMPLATE/ui-task.md deleted file mode 100644 index 2f42a594..00000000 --- a/.github/ISSUE_TEMPLATE/ui-task.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: UI task -about: new tasks of UI -title: UI TASK -labels: mvp, nice-to-have, tech-debt, enhancement -assignees: '' - ---- - -** Purpose** -A clear and concise description of this new task or feature - -** Purpose** -A clear and concise description of what you want to happen. - -**Design link** -Links of design in invisionApp, mockflow, zeiplin, etc - -**Criteria of acceptance** -List the parameters that the task must meet to be approved. -- parameter one -- parameter two -- ... - -**Note** -Information adicional, for example links of documentation to work in xz task. From ac387081c2ecab614e25873a6d85f9883251a273 Mon Sep 17 00:00:00 2001 From: semantic-release Date: Sat, 14 Nov 2020 14:36:40 +0000 Subject: [PATCH 05/10] 0.24.4 Automatically generated by python-semantic-release --- CHANGELOG.md | 6 ++++++ time_tracker_api/version.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 956d2902..d408f7e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ +## v0.24.4 (2020-11-14) +### Fix +* Delete ui-task template ([`0be1370`](https://github.com/ioet/time-tracker-backend/commit/0be1370d81f4dcec739ed2bf8f3eff25640af36b)) +* Issue templates ([`55b73bb`](https://github.com/ioet/time-tracker-backend/commit/55b73bb9cc546306f2c81785581fd593d71172fe)) +* Issue templates ([`76728f4`](https://github.com/ioet/time-tracker-backend/commit/76728f491820aa95d1f45ddb2565bd05ed34648f)) + ## v0.24.3 (2020-11-10) ### Fix * Allow limits overlap in time entries #217 ([`ce99603`](https://github.com/ioet/time-tracker-backend/commit/ce996032bf4cf20c129b84ad293db4c031571c95)) diff --git a/time_tracker_api/version.py b/time_tracker_api/version.py index c6d6a56b..1f4f7fb6 100644 --- a/time_tracker_api/version.py +++ b/time_tracker_api/version.py @@ -1 +1 @@ -__version__ = '0.24.3' +__version__ = '0.24.4' From 8bf29cd20de17e1797e4b70a7c8ed567376befe8 Mon Sep 17 00:00:00 2001 From: roberto Date: Thu, 12 Nov 2020 13:48:17 -0500 Subject: [PATCH 06/10] feat: update user role #229 --- time_tracker_api/users/users_namespace.py | 26 +++++++++++ utils/azure_users.py | 57 ++++++++++++++++------- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/time_tracker_api/users/users_namespace.py b/time_tracker_api/users/users_namespace.py index 80d40139..7c05cf62 100644 --- a/time_tracker_api/users/users_namespace.py +++ b/time_tracker_api/users/users_namespace.py @@ -36,6 +36,19 @@ user_response_fields.update(common_fields) +user_input_fields = ns.model( + 'UserInput', + { + 'role': fields.String( + title="User's Role", + required=True, + max_length=50, + description='Role assigned to the user by the tenant', + example=faker.word(['admin']), + ), + }, +) + @ns.route('') class Users(Resource): @@ -59,3 +72,16 @@ class User(Resource): def get(self, id): """Get an user""" return {} + + @ns.doc('update_user') + @ns.expect(user_input_fields) + @ns.response( + HTTPStatus.BAD_REQUEST, 'Invalid format or structure of the user' + ) + @ns.marshal_with(user_response_fields) + def put(self, id): + """Update an user""" + from utils.azure_users import AzureConnection + + azure_connection = AzureConnection() + return azure_connection.update_user_role(id, ns.payload['role']) diff --git a/utils/azure_users.py b/utils/azure_users.py index 700b654f..21c3f61e 100644 --- a/utils/azure_users.py +++ b/utils/azure_users.py @@ -1,6 +1,7 @@ import msal import os import requests +import json from typing import List @@ -65,22 +66,6 @@ def get_token(self): raise ValueError(error_info) def users(self) -> List[AzureUser]: - def to_azure_user(item) -> AzureUser: - there_is_email = len(item['otherMails']) > 0 - there_is_role = ( - 'extension_1d76efa96f604499acc0c0ee116a1453_role' in item - ) - - id = item['objectId'] - name = item['displayName'] - email = item['otherMails'][0] if there_is_email else '' - role = ( - item['extension_1d76efa96f604499acc0c0ee116a1453_role'] - if there_is_role - else None - ) - return AzureUser(id, name, email, role) - endpoint = "{endpoint}/users?api-version=1.6&$select=displayName,otherMails,objectId,{role_field}".format( endpoint=self.config.ENDPOINT, role_field='extension_1d76efa96f604499acc0c0ee116a1453_role', @@ -89,4 +74,42 @@ def to_azure_user(item) -> AzureUser: assert 200 == response.status_code assert 'value' in response.json() - return [to_azure_user(item) for item in response.json()['value']] + return [self.to_azure_user(item) for item in response.json()['value']] + + def update_user_role(self, id, role): + headers = { + 'Content-type': 'application/json', + 'Accept': 'application/json', + } + endpoint = "{endpoint}/users/{user_id}?api-version=1.6".format( + endpoint=self.config.ENDPOINT, user_id=id + ) + data = {'extension_1d76efa96f604499acc0c0ee116a1453_role': role} + response = requests.patch( + endpoint, + auth=BearerAuth(self.access_token), + data=json.dumps(data), + headers=headers, + ) + assert 204 == response.status_code + + response = requests.get(endpoint, auth=BearerAuth(self.access_token)) + assert 200 == response.status_code + + return self.to_azure_user(response.json()) + + def to_azure_user(self, item) -> AzureUser: + there_is_email = len(item['otherMails']) > 0 + there_is_role = ( + 'extension_1d76efa96f604499acc0c0ee116a1453_role' in item + ) + + id = item['objectId'] + name = item['displayName'] + email = item['otherMails'][0] if there_is_email else '' + role = ( + item['extension_1d76efa96f604499acc0c0ee116a1453_role'] + if there_is_role + else None + ) + return AzureUser(id, name, email, role) From 3d92e767ae8c135fdc3fe234f43e49f543c08b17 Mon Sep 17 00:00:00 2001 From: magallegos1996 Date: Thu, 12 Nov 2020 17:47:31 -0500 Subject: [PATCH 07/10] feat: testing for update user role #229 --- .../users/users_namespace_test.py | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/time_tracker_api/users/users_namespace_test.py b/tests/time_tracker_api/users/users_namespace_test.py index dfca1e93..d7e5e2fa 100644 --- a/tests/time_tracker_api/users/users_namespace_test.py +++ b/tests/time_tracker_api/users/users_namespace_test.py @@ -1,8 +1,14 @@ -from unittest.mock import Mock +from unittest.mock import Mock, patch from flask import json from flask.testing import FlaskClient from flask_restplus._http import HTTPStatus from utils.azure_users import AzureConnection +from faker import Faker + +fake = Faker() + +valid_user_role_data = {'role': 'admin'} +user_id = fake.random_int(1, 9999) def test_users_response_contains_expected_props( @@ -23,3 +29,37 @@ def test_users_response_contains_expected_props( assert 'name' in json.loads(response.data)[0] assert 'email' in json.loads(response.data)[0] assert 'role' in json.loads(response.data)[0] + + +def test_update_user_role_response_contains_expected_props( + client: FlaskClient, + valid_header: dict, +): + AzureConnection.update_user_role = Mock( + return_value=[{'name': 'dummy', 'email': 'dummy', 'role': 'dummy'}] + ) + + response = client.put( + f'/users/{user_id}', headers=valid_header, json=valid_user_role_data + ) + + assert HTTPStatus.OK == response.status_code + assert 'name' in json.loads(response.data)[0] + assert 'email' in json.loads(response.data)[0] + assert 'role' in json.loads(response.data)[0] + + +@patch('utils.azure_users.AzureConnection', new_callable=Mock) +def test_update_user_role_is_being_called_with_valid_arguments( + update_user_role_mock, + client: FlaskClient, + valid_header: dict, +): + + response = client.put( + f'/users/{user_id}', headers=valid_header, json=valid_user_role_data + ) + + assert HTTPStatus.OK == response.status_code + assert valid_user_role_data['role'] == 'admin' + update_user_role_mock.assert_called_once() From b918fccbd4d672e1074e7c96757f7cf9f87cb679 Mon Sep 17 00:00:00 2001 From: magallegos1996 Date: Fri, 13 Nov 2020 11:34:26 -0500 Subject: [PATCH 08/10] feat: add new fixture user_id testing update user role is being called with expected arguments #229 --- tests/conftest.py | 11 +++++++++- .../users/users_namespace_test.py | 21 +++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5cb5c18d..6ecfb5be 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -84,7 +84,11 @@ def cosmos_db_model(): return { 'id': 'test', 'partition_key': PartitionKey(path='/tenant_id'), - 'unique_key_policy': {'uniqueKeys': [{'paths': ['/email']},]}, + 'unique_key_policy': { + 'uniqueKeys': [ + {'paths': ['/email']}, + ] + }, } @@ -136,6 +140,11 @@ def owner_id() -> str: return fake.uuid4() +@pytest.fixture(scope="session") +def user_id() -> str: + return fake.uuid4() + + @pytest.fixture(scope="function") def sample_item( cosmos_db_repository: CosmosDBRepository, diff --git a/tests/time_tracker_api/users/users_namespace_test.py b/tests/time_tracker_api/users/users_namespace_test.py index d7e5e2fa..a0c66d5a 100644 --- a/tests/time_tracker_api/users/users_namespace_test.py +++ b/tests/time_tracker_api/users/users_namespace_test.py @@ -7,9 +7,6 @@ fake = Faker() -valid_user_role_data = {'role': 'admin'} -user_id = fake.random_int(1, 9999) - def test_users_response_contains_expected_props( client: FlaskClient, @@ -34,9 +31,11 @@ def test_users_response_contains_expected_props( def test_update_user_role_response_contains_expected_props( client: FlaskClient, valid_header: dict, + user_id: dict, ): + valid_user_role_data = {'role': 'admin'} AzureConnection.update_user_role = Mock( - return_value=[{'name': 'dummy', 'email': 'dummy', 'role': 'dummy'}] + return_value={'name': 'dummy', 'email': 'dummy', 'role': 'dummy'} ) response = client.put( @@ -44,22 +43,26 @@ def test_update_user_role_response_contains_expected_props( ) assert HTTPStatus.OK == response.status_code - assert 'name' in json.loads(response.data)[0] - assert 'email' in json.loads(response.data)[0] - assert 'role' in json.loads(response.data)[0] + assert 'name' in json.loads(response.data) + assert 'email' in json.loads(response.data) + assert 'role' in json.loads(response.data) -@patch('utils.azure_users.AzureConnection', new_callable=Mock) +@patch('utils.azure_users.AzureConnection.update_user_role', new_callable=Mock) def test_update_user_role_is_being_called_with_valid_arguments( update_user_role_mock, client: FlaskClient, valid_header: dict, + user_id: dict, ): + valid_user_role_data = {'role': 'admin'} response = client.put( f'/users/{user_id}', headers=valid_header, json=valid_user_role_data ) assert HTTPStatus.OK == response.status_code assert valid_user_role_data['role'] == 'admin' - update_user_role_mock.assert_called_once() + update_user_role_mock.assert_called_once_with( + user_id, valid_user_role_data['role'] + ) From 34c990fcfeb174957306732305a0be6d3433afb6 Mon Sep 17 00:00:00 2001 From: magallegos1996 Date: Fri, 13 Nov 2020 12:36:15 -0500 Subject: [PATCH 09/10] feat: response and user input fields now accepts a null value in their role field #229 --- tests/time_tracker_api/users/users_namespace_test.py | 8 ++------ time_tracker_api/users/users_namespace.py | 10 +++++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/time_tracker_api/users/users_namespace_test.py b/tests/time_tracker_api/users/users_namespace_test.py index a0c66d5a..a4d49afe 100644 --- a/tests/time_tracker_api/users/users_namespace_test.py +++ b/tests/time_tracker_api/users/users_namespace_test.py @@ -3,9 +3,6 @@ from flask.testing import FlaskClient from flask_restplus._http import HTTPStatus from utils.azure_users import AzureConnection -from faker import Faker - -fake = Faker() def test_users_response_contains_expected_props( @@ -31,7 +28,7 @@ def test_users_response_contains_expected_props( def test_update_user_role_response_contains_expected_props( client: FlaskClient, valid_header: dict, - user_id: dict, + user_id: str, ): valid_user_role_data = {'role': 'admin'} AzureConnection.update_user_role = Mock( @@ -53,7 +50,7 @@ def test_update_user_role_is_being_called_with_valid_arguments( update_user_role_mock, client: FlaskClient, valid_header: dict, - user_id: dict, + user_id: str, ): valid_user_role_data = {'role': 'admin'} @@ -62,7 +59,6 @@ def test_update_user_role_is_being_called_with_valid_arguments( ) assert HTTPStatus.OK == response.status_code - assert valid_user_role_data['role'] == 'admin' update_user_role_mock.assert_called_once_with( user_id, valid_user_role_data['role'] ) diff --git a/time_tracker_api/users/users_namespace.py b/time_tracker_api/users/users_namespace.py index 7c05cf62..ed6e194b 100644 --- a/time_tracker_api/users/users_namespace.py +++ b/time_tracker_api/users/users_namespace.py @@ -2,7 +2,7 @@ from flask_restplus import fields, Resource from flask_restplus._http import HTTPStatus -from time_tracker_api.api import common_fields, api +from time_tracker_api.api import common_fields, api, NullableString faker = Faker() @@ -25,11 +25,11 @@ description='Email of the user that belongs to the tenant', example=faker.email(), ), - 'role': fields.String( + 'role': NullableString( title="User's Role", max_length=50, description='Role assigned to the user by the tenant', - example=faker.word(['admin']), + example=faker.word(['time-tracker-admin']), ), }, ) @@ -39,12 +39,12 @@ user_input_fields = ns.model( 'UserInput', { - 'role': fields.String( + 'role': NullableString( title="User's Role", required=True, max_length=50, description='Role assigned to the user by the tenant', - example=faker.word(['admin']), + example=faker.word(['time-tracker-admin']), ), }, ) From 82993299bb6046a9ff58816a45188ecb4a66cc3d Mon Sep 17 00:00:00 2001 From: roberto Date: Mon, 16 Nov 2020 11:48:10 -0500 Subject: [PATCH 10/10] feat: update url #229 --- .../users/users_namespace_test.py | 20 +++++++++---------- time_tracker_api/users/users_namespace.py | 14 ++++--------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/tests/time_tracker_api/users/users_namespace_test.py b/tests/time_tracker_api/users/users_namespace_test.py index a4d49afe..7cbef2cb 100644 --- a/tests/time_tracker_api/users/users_namespace_test.py +++ b/tests/time_tracker_api/users/users_namespace_test.py @@ -6,18 +6,14 @@ def test_users_response_contains_expected_props( - client: FlaskClient, - valid_header: dict, + client: FlaskClient, valid_header: dict, ): AzureConnection.users = Mock( return_value=[{'name': 'dummy', 'email': 'dummy', 'role': 'dummy'}] ) - response = client.get( - '/users', - headers=valid_header, - ) + response = client.get('/users', headers=valid_header,) assert HTTPStatus.OK == response.status_code assert 'name' in json.loads(response.data)[0] @@ -26,9 +22,7 @@ def test_users_response_contains_expected_props( def test_update_user_role_response_contains_expected_props( - client: FlaskClient, - valid_header: dict, - user_id: str, + client: FlaskClient, valid_header: dict, user_id: str, ): valid_user_role_data = {'role': 'admin'} AzureConnection.update_user_role = Mock( @@ -36,7 +30,9 @@ def test_update_user_role_response_contains_expected_props( ) response = client.put( - f'/users/{user_id}', headers=valid_header, json=valid_user_role_data + f'/users/{user_id}/roles', + headers=valid_header, + json=valid_user_role_data, ) assert HTTPStatus.OK == response.status_code @@ -55,7 +51,9 @@ def test_update_user_role_is_being_called_with_valid_arguments( valid_user_role_data = {'role': 'admin'} response = client.put( - f'/users/{user_id}', headers=valid_header, json=valid_user_role_data + f'/users/{user_id}/roles', + headers=valid_header, + json=valid_user_role_data, ) assert HTTPStatus.OK == response.status_code diff --git a/time_tracker_api/users/users_namespace.py b/time_tracker_api/users/users_namespace.py index ed6e194b..b3372a31 100644 --- a/time_tracker_api/users/users_namespace.py +++ b/time_tracker_api/users/users_namespace.py @@ -62,25 +62,19 @@ def get(self): return azure_connection.users() -@ns.route('/') +@ns.route('//roles') @ns.response(HTTPStatus.NOT_FOUND, 'User not found') @ns.response(HTTPStatus.UNPROCESSABLE_ENTITY, 'The id has an invalid format') @ns.param('id', 'The user identifier') -class User(Resource): - @ns.doc('get_user') - @ns.marshal_with(user_response_fields) - def get(self, id): - """Get an user""" - return {} - - @ns.doc('update_user') +class UserRole(Resource): + @ns.doc('update_user_role') @ns.expect(user_input_fields) @ns.response( HTTPStatus.BAD_REQUEST, 'Invalid format or structure of the user' ) @ns.marshal_with(user_response_fields) def put(self, id): - """Update an user""" + """Update user's role""" from utils.azure_users import AzureConnection azure_connection = AzureConnection()