@@ -761,18 +761,22 @@ def test_get_all_role_assignments_in_scope(self, scope_name, expected_assignment
761761 # Test user with single role in single scope
762762 ("alice" , ["lib:Org1:math_101" ], {"library_admin" }),
763763 # Test user with multiple roles in different scopes
764- ("eve" , ["lib:Org2:physics_401" , "lib:Org2:chemistry_501" , "lib:Org2:biology_601" ],
765- {"library_admin" , "library_author" , "library_user" }),
764+ (
765+ "eve" ,
766+ ["lib:Org2:physics_401" , "lib:Org2:chemistry_501" , "lib:Org2:biology_601" ],
767+ {"library_admin" , "library_author" , "library_user" },
768+ ),
766769 # Test user with same role in multiple scopes
767770 ("liam" , ["lib:Org4:art_101" , "lib:Org4:art_201" , "lib:Org4:art_301" ], {"library_author" }),
768771 # Test user with multiple different roles in multiple scopes
769- ("peter" , ["lib:Org6:project_alpha" , "lib:Org6:project_beta" , "lib:Org6:project_gamma" , "lib:Org6:project_delta" ],
770- {"library_admin" , "library_author" , "library_contributor" , "library_user" }),
772+ (
773+ "peter" ,
774+ ["lib:Org6:project_alpha" , "lib:Org6:project_beta" , "lib:Org6:project_gamma" , "lib:Org6:project_delta" ],
775+ {"library_admin" , "library_author" , "library_contributor" , "library_user" },
776+ ),
771777 )
772778 @unpack
773- def test_unassign_subject_from_all_roles_removes_all_assignments (
774- self , subject_name , scopes , expected_roles_before
775- ):
779+ def test_unassign_subject_from_all_roles_removes_all_assignments (self , subject_name , scopes , expected_roles_before ):
776780 """Test that unassign_subject_from_all_roles removes all role assignments.
777781
778782 Expected result:
@@ -788,16 +792,12 @@ def test_unassign_subject_from_all_roles_removes_all_assignments(
788792 self .assertGreater (len (assignments_before ), 0 )
789793
790794 # Verify roles are what we expect before removal
791- roles_before = {
792- r .external_key for assignment in assignments_before for r in assignment .roles
793- }
795+ roles_before = {r .external_key for assignment in assignments_before for r in assignment .roles }
794796 self .assertEqual (roles_before , expected_roles_before )
795797
796798 # Verify assignments exist in each expected scope
797799 for scope_name in scopes :
798- scope_assignments = get_subject_role_assignments_in_scope (
799- subject , ScopeData (external_key = scope_name )
800- )
800+ scope_assignments = get_subject_role_assignments_in_scope (subject , ScopeData (external_key = scope_name ))
801801 self .assertGreater (len (scope_assignments ), 0 )
802802
803803 # Unassign all roles from the subject
@@ -812,9 +812,7 @@ def test_unassign_subject_from_all_roles_removes_all_assignments(
812812
813813 # Verify no assignments in any of the previous scopes
814814 for scope_name in scopes :
815- scope_assignments = get_subject_role_assignments_in_scope (
816- subject , ScopeData (external_key = scope_name )
817- )
815+ scope_assignments = get_subject_role_assignments_in_scope (subject , ScopeData (external_key = scope_name ))
818816 self .assertEqual (len (scope_assignments ), 0 )
819817
820818 def test_unassign_subject_with_no_roles_returns_false (self ):
@@ -853,12 +851,8 @@ def test_unassign_subject_does_not_affect_other_subjects(self):
853851 shared_scope = ScopeData (external_key = "lib:Org1:math_advanced" )
854852
855853 # Verify both subjects have roles in the shared scope before
856- grace_assignments_before = get_subject_role_assignments_in_scope (
857- subject_to_unassign , shared_scope
858- )
859- heidi_assignments_before = get_subject_role_assignments_in_scope (
860- other_subject , shared_scope
861- )
854+ grace_assignments_before = get_subject_role_assignments_in_scope (subject_to_unassign , shared_scope )
855+ heidi_assignments_before = get_subject_role_assignments_in_scope (other_subject , shared_scope )
862856
863857 self .assertGreater (len (grace_assignments_before ), 0 )
864858 self .assertGreater (len (heidi_assignments_before ), 0 )
@@ -872,17 +866,11 @@ def test_unassign_subject_does_not_affect_other_subjects(self):
872866 self .assertEqual (len (grace_assignments_after ), 0 )
873867
874868 # Verify heidi still has her assignments
875- heidi_assignments_after = get_subject_role_assignments_in_scope (
876- other_subject , shared_scope
877- )
869+ heidi_assignments_after = get_subject_role_assignments_in_scope (other_subject , shared_scope )
878870 self .assertEqual (len (heidi_assignments_after ), len (heidi_assignments_before ))
879871
880872 # Verify heidi still has the library_contributor role
881- heidi_roles = {
882- r .external_key
883- for assignment in heidi_assignments_after
884- for r in assignment .roles
885- }
873+ heidi_roles = {r .external_key for assignment in heidi_assignments_after for r in assignment .roles }
886874 self .assertIn ("library_contributor" , heidi_roles )
887875
888876 def test_unassign_and_reassign_subject (self ):
@@ -919,7 +907,5 @@ def test_unassign_and_reassign_subject(self):
919907 new_assignments = get_subject_role_assignments_in_scope (subject , new_scope )
920908 self .assertEqual (len (new_assignments ), 1 )
921909
922- new_roles = {
923- r .external_key for assignment in new_assignments for r in assignment .roles
924- }
910+ new_roles = {r .external_key for assignment in new_assignments for r in assignment .roles }
925911 self .assertIn ("library_admin" , new_roles )
0 commit comments