Skip to content

Commit cb1011a

Browse files
feat: response and user input fields now accepts a null value in their role field #229
1 parent a98b987 commit cb1011a

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

tests/time_tracker_api/users/users_namespace_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
from flask.testing import FlaskClient
44
from flask_restplus._http import HTTPStatus
55
from utils.azure_users import AzureConnection
6-
from faker import Faker
7-
8-
fake = Faker()
96

107

118
def test_users_response_contains_expected_props(
@@ -31,7 +28,7 @@ def test_users_response_contains_expected_props(
3128
def test_update_user_role_response_contains_expected_props(
3229
client: FlaskClient,
3330
valid_header: dict,
34-
user_id: dict,
31+
user_id: str,
3532
):
3633
valid_user_role_data = {'role': 'admin'}
3734
AzureConnection.update_user_role = Mock(
@@ -53,7 +50,7 @@ def test_update_user_role_is_being_called_with_valid_arguments(
5350
update_user_role_mock,
5451
client: FlaskClient,
5552
valid_header: dict,
56-
user_id: dict,
53+
user_id: str,
5754
):
5855

5956
valid_user_role_data = {'role': 'admin'}
@@ -62,7 +59,6 @@ def test_update_user_role_is_being_called_with_valid_arguments(
6259
)
6360

6461
assert HTTPStatus.OK == response.status_code
65-
assert valid_user_role_data['role'] == 'admin'
6662
update_user_role_mock.assert_called_once_with(
6763
user_id, valid_user_role_data['role']
6864
)

time_tracker_api/users/users_namespace.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from flask_restplus import fields, Resource
33
from flask_restplus._http import HTTPStatus
44

5-
from time_tracker_api.api import common_fields, api
5+
from time_tracker_api.api import common_fields, api, NullableString
66

77
faker = Faker()
88

@@ -25,11 +25,11 @@
2525
description='Email of the user that belongs to the tenant',
2626
example=faker.email(),
2727
),
28-
'role': fields.String(
28+
'role': NullableString(
2929
title="User's Role",
3030
max_length=50,
3131
description='Role assigned to the user by the tenant',
32-
example=faker.word(['admin']),
32+
example=faker.word(['time-tracker-admin']),
3333
),
3434
},
3535
)
@@ -39,12 +39,12 @@
3939
user_input_fields = ns.model(
4040
'UserInput',
4141
{
42-
'role': fields.String(
42+
'role': NullableString(
4343
title="User's Role",
4444
required=True,
4545
max_length=50,
4646
description='Role assigned to the user by the tenant',
47-
example=faker.word(['admin']),
47+
example=faker.word(['time-tracker-admin']),
4848
),
4949
},
5050
)

0 commit comments

Comments
 (0)