Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: response and user input fields now accepts a null value in thei…
…r role field #229
  • Loading branch information
magallegos1996 authored and Angeluz-07 committed Nov 19, 2020
commit 47e21af989535ce587e6af00147a64779034faa7
8 changes: 2 additions & 6 deletions tests/time_tracker_api/users/users_namespace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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'}
Expand All @@ -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']
)
10 changes: 5 additions & 5 deletions time_tracker_api/users/users_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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']),
),
},
)
Expand All @@ -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']),
),
},
)
Expand Down