Skip to content

Commit 1df3d1b

Browse files
refactor: address PR review
1 parent 1d56639 commit 1df3d1b

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

openedx_authz/api/roles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"get_subject_role_assignments_for_role_in_scope",
4141
"get_all_subject_role_assignments_in_scope",
4242
"get_subject_role_assignments",
43-
"unassign_subjects_from_all_roles",
43+
"unassign_subject_from_all_roles",
4444
]
4545

4646
# TODO: these are the concerns we still have to address:
@@ -393,7 +393,7 @@ def get_subjects_for_role(role: RoleData) -> list[SubjectData]:
393393
return [SubjectData(namespaced_key=policy[GroupingPolicyIndex.SUBJECT.value]) for policy in policies]
394394

395395

396-
def unassign_subjects_from_all_roles(subject: SubjectData) -> bool:
396+
def unassign_subject_from_all_roles(subject: SubjectData) -> bool:
397397
"""Unassign a subject from all roles across all scopes.
398398
399399
Args:

openedx_authz/api/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
get_subject_role_assignments_in_scope,
2222
get_subjects_for_role,
2323
unassign_role_from_subject_in_scope,
24-
unassign_subjects_from_all_roles,
24+
unassign_subject_from_all_roles,
2525
)
2626

2727
__all__ = [
@@ -211,4 +211,4 @@ def unassign_all_roles_from_user(user_external_key: str) -> bool:
211211
Returns:
212212
bool: True if any roles were removed, False otherwise.
213213
"""
214-
return unassign_subjects_from_all_roles(UserData(external_key=user_external_key))
214+
return unassign_subject_from_all_roles(UserData(external_key=user_external_key))

openedx_authz/tests/api/test_roles.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
get_subject_role_assignments_for_role_in_scope,
2525
get_subject_role_assignments_in_scope,
2626
unassign_role_from_subject_in_scope,
27-
unassign_subjects_from_all_roles,
27+
unassign_subject_from_all_roles,
2828
)
2929
from openedx_authz.engine.enforcer import AuthzEnforcer
3030
from openedx_authz.engine.utils import migrate_policy_between_enforcers
@@ -773,7 +773,7 @@ def test_get_all_role_assignments_in_scope(self, scope_name, expected_assignment
773773
def test_unassign_subject_from_all_roles_removes_all_assignments(
774774
self, subject_name, scopes, expected_roles_before
775775
):
776-
"""Test that unassign_subjects_from_all_roles removes all role assignments.
776+
"""Test that unassign_subject_from_all_roles removes all role assignments.
777777
778778
Expected result:
779779
- Before unassignment: Subject has roles in specified scopes
@@ -801,7 +801,7 @@ def test_unassign_subject_from_all_roles_removes_all_assignments(
801801
self.assertGreater(len(scope_assignments), 0)
802802

803803
# Unassign all roles from the subject
804-
result = unassign_subjects_from_all_roles(subject)
804+
result = unassign_subject_from_all_roles(subject)
805805

806806
# Verify the function returns True (indicating roles were removed)
807807
self.assertTrue(result)
@@ -831,7 +831,7 @@ def test_unassign_subject_with_no_roles_returns_false(self):
831831
self.assertEqual(len(assignments_before), 0)
832832

833833
# Unassign all roles (should return False since there are none)
834-
result = unassign_subjects_from_all_roles(non_existent_subject)
834+
result = unassign_subject_from_all_roles(non_existent_subject)
835835

836836
# Verify the function returns False (no roles to remove)
837837
self.assertFalse(result)
@@ -864,7 +864,7 @@ def test_unassign_subject_does_not_affect_other_subjects(self):
864864
self.assertGreater(len(heidi_assignments_before), 0)
865865

866866
# Unassign all roles from grace
867-
result = unassign_subjects_from_all_roles(subject_to_unassign)
867+
result = unassign_subject_from_all_roles(subject_to_unassign)
868868
self.assertTrue(result)
869869

870870
# Verify grace has no assignments after unassignment
@@ -904,7 +904,7 @@ def test_unassign_and_reassign_subject(self):
904904
self.assertGreater(len(assignments_before), 0)
905905

906906
# Unassign all roles
907-
result = unassign_subjects_from_all_roles(subject)
907+
result = unassign_subject_from_all_roles(subject)
908908
self.assertTrue(result)
909909

910910
# Verify no roles after unassignment

0 commit comments

Comments
 (0)