Skip to content

Commit 836e018

Browse files
committed
TT-94 feat: add tests for proper call to azureconnection method
1 parent 467f440 commit 836e018

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/time_tracker_api/users/users_namespace_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from flask.testing import FlaskClient
44
from flask_restplus._http import HTTPStatus
55
from utils.azure_users import AzureConnection
6+
from pytest import mark
67

78

89
def test_users_response_contains_expected_props(
@@ -76,3 +77,32 @@ def test_on_delete_update_user_role_is_being_called_with_valid_arguments(
7677

7778
assert HTTPStatus.OK == response.status_code
7879
update_user_role_mock.assert_called_once_with(user_id, role=None)
80+
81+
82+
@patch('utils.azure_users.AzureConnection.update_role', new_callable=Mock)
83+
@mark.parametrize(
84+
'role_id,action,is_grant',
85+
[
86+
('admin', 'grant', True),
87+
('admin', 'revoke', False),
88+
('test', 'grant', True),
89+
('test', 'revoke', False),
90+
],
91+
)
92+
def test_update_role_is_called_properly_on_each_action(
93+
update_role_mock,
94+
client: FlaskClient,
95+
valid_header: dict,
96+
user_id: str,
97+
role_id,
98+
action,
99+
is_grant,
100+
):
101+
response = client.post(
102+
f'/users/{user_id}/roles/{role_id}/{action}', headers=valid_header,
103+
)
104+
105+
assert HTTPStatus.OK == response.status_code
106+
update_role_mock.assert_called_once_with(
107+
user_id, role_id, is_grant=is_grant
108+
)

0 commit comments

Comments
 (0)