Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions cms/djangoapps/contentstore/tests/test_course_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,48 @@ def test_org_limited_staff_course_listing(self):
# Limited Course Staff should not be able to list courses in Studio
assert len(list(courses_list_by_staff)) == 0

def test_course_limited_staff_course_listing(self):
# Setup a new course
course_location = self.store.make_course_key('Org', 'CreatedCourse', 'Run')
CourseFactory.create(
org=course_location.org,
number=course_location.course,
run=course_location.run
)
course = CourseOverviewFactory.create(id=course_location, org=course_location.org)

# Add the user as a course_limited_staff on the course
CourseLimitedStaffRole(course.id).add_users(self.user)
self.assertTrue(CourseLimitedStaffRole(course.id).has_user(self.user))

# Fetch accessible courses list & verify their count
courses_list_by_staff, __ = get_courses_accessible_to_user(self.request)

# Limited Course Staff should not be able to list courses in Studio
assert len(list(courses_list_by_staff)) == 0

def test_org_limited_staff_course_listing(self):

# Setup a new course
course_location = self.store.make_course_key('Org', 'CreatedCourse', 'Run')
CourseFactory.create(
org=course_location.org,
number=course_location.course,
run=course_location.run
)
course = CourseOverviewFactory.create(id=course_location, org=course_location.org)

# Add a user as course_limited_staff on the org
# This is not possible using the course roles classes but is possible via Django admin so we
# insert a row into the model directly to test that scenario.
CourseAccessRole.objects.create(user=self.user, org=course_location.org, role=CourseLimitedStaffRole.ROLE)

# Fetch accessible courses list & verify their count
courses_list_by_staff, __ = get_courses_accessible_to_user(self.request)

# Limited Course Staff should not be able to list courses in Studio
assert len(list(courses_list_by_staff)) == 0

def test_get_course_list_with_invalid_course_location(self):
"""
Test getting courses with invalid course location (course deleted from modulestore).
Expand Down
Loading