diff --git a/common/djangoapps/student/roles.py b/common/djangoapps/student/roles.py index e61fafe89aa1..f96cc5f35375 100644 --- a/common/djangoapps/student/roles.py +++ b/common/djangoapps/student/roles.py @@ -90,7 +90,7 @@ def has_role(self, role, course_id, org): return any( access_role.role in self.get_roles(role) and access_role.course_id == course_id and - access_role.org == org + access_role.org.lower() == org.lower() for access_role in self._roles ) diff --git a/common/djangoapps/student/tests/test_roles.py b/common/djangoapps/student/tests/test_roles.py index 6c344352a142..ff8023003cf5 100644 --- a/common/djangoapps/student/tests/test_roles.py +++ b/common/djangoapps/student/tests/test_roles.py @@ -162,8 +162,10 @@ class RoleCacheTestCase(TestCase): # lint-amnesty, pylint: disable=missing-clas ROLES = ( (CourseStaffRole(IN_KEY), ('staff', IN_KEY, 'edX')), + (CourseStaffRole(IN_KEY), ('staff', IN_KEY, 'EDX')), (CourseInstructorRole(IN_KEY), ('instructor', IN_KEY, 'edX')), (OrgStaffRole(IN_KEY.org), ('staff', None, 'edX')), + (OrgStaffRole(IN_KEY.org), ('staff', None, 'EDX')), (OrgInstructorRole(IN_KEY.org), ('instructor', None, 'edX')), (CourseBetaTesterRole(IN_KEY), ('beta_testers', IN_KEY, 'edX')), ) @@ -180,10 +182,13 @@ def test_only_in_role(self, role, target): assert cache.has_role(*target) for other_role, other_target in self.ROLES: - if other_role == role: - continue + expected_has_role = ( + other_role.ROLE == role.ROLE and + other_role.org.lower() == role.org.lower() and + other_role.course_key == role.course_key + ) - assert not cache.has_role(*other_target) + assert cache.has_role(*other_target) == expected_has_role @ddt.data(*ROLES) @ddt.unpack