Skip to content

Commit 9d195a2

Browse files
author
Matthew Fortunka
committed
more linting fixes
1 parent c8908e0 commit 9d195a2

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

api_app/services/aad_authentication.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _get_users_inc_groups_from_response(self, users_graph_data, roles_graph_data
281281
if "users" in user_data["body"]["@odata.context"]:
282282
user_email = user_data["body"]["userPrincipalName"]
283283
# if user with id does not already exist in users
284-
user_roles=self._get_roles_for_principal(user_id, roles_graph_data, app_id_to_role_name)
284+
user_roles = self._get_roles_for_principal(user_id, roles_graph_data, app_id_to_role_name)
285285

286286
if not any(user.id == user_id for user in users):
287287
users.append(User(id=user_id, name=user_name, email=user_email, roles=user_roles))
@@ -297,7 +297,7 @@ def _get_users_inc_groups_from_response(self, users_graph_data, roles_graph_data
297297
user_name = group_member["displayName"]
298298
user_email = group_member["userPrincipalName"]
299299

300-
group_roles=self._get_roles_for_principal(group_id, roles_graph_data, app_id_to_role_name)
300+
group_roles = self._get_roles_for_principal(group_id, roles_graph_data, app_id_to_role_name)
301301

302302
if not any(user.id == user_id for user in users):
303303
users.append(User(id=user_id, name=user_name, email=user_email, roles=group_roles))
@@ -339,11 +339,11 @@ def get_workspace_roles(self, workspace: Workspace) -> List[Role]:
339339

340340
for role in graph_data["value"]:
341341
roles.append(Role(id=role["id"], value=role["value"],
342-
isEnabled=role["isEnabled"],
343-
description=role["description"],
344-
displayName=role["displayName"],
345-
origin=role["origin"],
346-
allowedMemberTypes=role["allowedMemberTypes"]))
342+
isEnabled=role["isEnabled"],
343+
description=role["description"],
344+
displayName=role["displayName"],
345+
origin=role["origin"],
346+
allowedMemberTypes=role["allowedMemberTypes"]))
347347

348348
return roles
349349

api_app/tests_ma/test_api/test_routes/test_workspace_users.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ async def test_assign_workspace_user_assigns_workspace_user(self, get_workspace_
124124
@patch("api.dependencies.workspaces.WorkspaceRepository.get_workspace_by_id", return_value=sample_workspace())
125125
async def test_remove_workspace_user_assignment_removes_workspace_user_assignment(self, get_workspace_by_id_mock, auth_class, app, client):
126126
with patch(f"services.{auth_class}.remove_workspace_role_user_assignment") as remove_workspace_role_user_assignment_mock, \
127-
patch(f"services.{auth_class}.get_user_by_email") as get_user_by_email_mock, \
128-
patch(f"services.{auth_class}.get_workspace_role_by_name") as get_workspace_role_by_name_mock, \
129-
patch(f"services.{auth_class}.get_workspace_users") as get_workspace_users_mock:
127+
patch(f"services.{auth_class}.get_user_by_email") as get_user_by_email_mock, \
128+
patch(f"services.{auth_class}.get_workspace_role_by_name") as get_workspace_role_by_name_mock, \
129+
patch(f"services.{auth_class}.get_workspace_users") as get_workspace_users_mock:
130130

131131
workspace = get_workspace_by_id_mock.return_value
132132

api_app/tests_ma/test_services/test_aad_access_service.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,9 @@ def test_assign_workspace_user_already_has_role(workspace_role_in_use_mock,
765765
@patch("services.aad_authentication.AzureADAuthorization._is_workspace_role_group_in_use", return_value=False)
766766
@patch("services.aad_authentication.AzureADAuthorization._assign_workspace_user_to_application_group")
767767
@patch("services.aad_authentication.AzureADAuthorization._assign_workspace_user_to_application")
768-
def test_assign_workspace_user_if_no_groups(assign_user_to_role_mock,assign_user_to_group_mock,
769-
workspace_without_groups, role_owner,
770-
user_with_role):
768+
def test_assign_workspace_user_if_no_groups(assign_user_to_role_mock, assign_user_to_group_mock,
769+
workspace_without_groups, role_owner,
770+
user_with_role):
771771

772772
access_service = AzureADAuthorization()
773773
assign_user_to_role_mock.return_value = None
@@ -782,9 +782,9 @@ def test_assign_workspace_user_if_no_groups(assign_user_to_role_mock,assign_user
782782
@patch("services.aad_authentication.AzureADAuthorization._is_workspace_role_group_in_use", return_value=True)
783783
@patch("services.aad_authentication.AzureADAuthorization._assign_workspace_user_to_application_group")
784784
@patch("services.aad_authentication.AzureADAuthorization._assign_workspace_user_to_application")
785-
def test_assign_workspace_user_if_groups(assign_user_to_role_mock,assign_user_to_group_mock,
786-
workspace_without_groups, role_owner,
787-
user_with_role):
785+
def test_assign_workspace_user_if_groups(assign_user_to_role_mock, assign_user_to_group_mock,
786+
workspace_without_groups, role_owner,
787+
user_with_role):
788788

789789
access_service = AzureADAuthorization()
790790
assign_user_to_role_mock.return_value = None
@@ -801,8 +801,8 @@ def test_assign_workspace_user_if_groups(assign_user_to_role_mock,assign_user_to
801801
@patch("services.aad_authentication.AzureADAuthorization._get_role_assignment_for_user")
802802
def test_remove_workspace_user_if_no_groups(get_role_assignment_mock,
803803
remove_user_to_role_mock, remove_user_to_group_mock,
804-
workspace_without_groups, role_owner,
805-
user_with_role):
804+
workspace_without_groups, role_owner,
805+
user_with_role):
806806

807807
access_service = AzureADAuthorization()
808808
remove_user_to_role_mock.return_value = None
@@ -819,9 +819,9 @@ def test_remove_workspace_user_if_no_groups(get_role_assignment_mock,
819819
@patch("services.aad_authentication.AzureADAuthorization._remove_workspace_user_from_application")
820820
@patch("services.aad_authentication.AzureADAuthorization._get_role_assignment_for_user")
821821
def test_remove_workspace_user_if_groups(get_role_assignment_mock,
822-
remove_user_to_role_mock, remove_user_to_group_mock,
823-
workspace_without_groups, role_owner,
824-
user_with_role):
822+
remove_user_to_role_mock, remove_user_to_group_mock,
823+
workspace_without_groups, role_owner,
824+
user_with_role):
825825

826826
access_service = AzureADAuthorization()
827827
remove_user_to_role_mock.return_value = None
@@ -840,7 +840,7 @@ def test_get_assignable_users_returns_users(_, request_get_mock, mock_headers):
840840
access_service = AzureADAuthorization()
841841

842842
# mock the response of _get_auth_header
843-
headers = {"Authorization": f"Bearer token"}
843+
headers = {"Authorization": "Bearer token"}
844844
mock_headers.return_value = headers
845845
headers["Content-type"] = "application/json"
846846

@@ -864,22 +864,22 @@ def test_get_assignable_users_returns_users(_, request_get_mock, mock_headers):
864864
@patch("services.aad_authentication.AzureADAuthorization._get_msgraph_token", return_value="token")
865865
@patch("services.aad_authentication.AzureADAuthorization._ms_graph_query")
866866
@patch("services.aad_authentication.AzureADAuthorization._get_auth_header")
867-
def test_get_workspace_roles_returns_roles(_, ms_graph_query_mock, mock_headers,workspace_without_groups):
867+
def test_get_workspace_roles_returns_roles(_, ms_graph_query_mock, mock_headers, workspace_without_groups):
868868
access_service = AzureADAuthorization()
869869

870870
# mock the response of _get_auth_header
871-
headers = {"Authorization": f"Bearer token"}
871+
headers = {"Authorization": "Bearer token"}
872872
mock_headers.return_value = headers
873873
headers["Content-type"] = "application/json"
874874

875875
# Mock the response of the get request
876876
request_get_mock_response = {
877-
"value": [
877+
"value":[
878878
Role(id=1, value="AirlockManager", isEnabled=True, description="", displayName="Airlock Manager", origin="", allowedMemberTypes=[]).dict(),
879879
Role(id=2, value="WorkspaceResearcher", isEnabled=True, description="", displayName="Workspace Researcher", origin="", allowedMemberTypes=[]).dict(),
880880
Role(id=3, value="WorkspaceOwner", isEnabled=True, description="", displayName="Workspace Owner", origin="", allowedMemberTypes=[]).dict(),
881-
]
882-
}
881+
]
882+
}
883883
ms_graph_query_mock.return_value = request_get_mock_response
884884
roles = access_service.get_workspace_roles(workspace_without_groups)
885885

0 commit comments

Comments
 (0)