|
19 | 19 | from cms.djangoapps.contentstore.tests.utils import AjaxEnabledTestClient, CourseTestCase, parse_json |
20 | 20 | from cms.djangoapps.contentstore.utils import reverse_course_url, reverse_library_url |
21 | 21 | from cms.djangoapps.course_creators.views import add_user_with_status_granted as grant_course_creator_status |
22 | | -from common.djangoapps.student.roles import LibraryUserRole, CourseStaffRole |
| 22 | +from common.djangoapps.student.roles import LibraryUserRole, CourseStaffRole, CourseInstructorRole |
23 | 23 | from xmodule.modulestore.tests.factories import LibraryFactory # lint-amnesty, pylint: disable=wrong-import-order |
24 | 24 | from cms.djangoapps.course_creators.models import CourseCreator |
25 | 25 |
|
@@ -101,6 +101,14 @@ def test_library_creator_status_with_course_staff_role_for_enabled_creator_group |
101 | 101 | auth.add_users(self.user, CourseStaffRole(self.course.id), nostaff_user) |
102 | 102 | self.assertEqual(user_can_create_library(nostaff_user), True) |
103 | 103 |
|
| 104 | + # When creator groups are enabled, course instructor members can create libraries |
| 105 | + @mock.patch("cms.djangoapps.contentstore.views.library.LIBRARIES_ENABLED", True) |
| 106 | + def test_library_creator_status_with_course_instructor_role_for_enabled_creator_group_setting(self): |
| 107 | + _, nostaff_user = self.create_non_staff_authed_user_client() |
| 108 | + with mock.patch.dict('django.conf.settings.FEATURES', {"ENABLE_CREATOR_GROUP": True}): |
| 109 | + auth.add_users(self.user, CourseInstructorRole(self.course.id), nostaff_user) |
| 110 | + self.assertEqual(user_can_create_library(nostaff_user), True) |
| 111 | + |
104 | 112 | @ddt.data( |
105 | 113 | (False, False, True), |
106 | 114 | (False, True, False), |
@@ -480,9 +488,14 @@ def test_allowed_organizations_for_library(self): |
480 | 488 | # Assert that the method returned the expected value |
481 | 489 | self.assertEqual(organizations, []) |
482 | 490 | with mock.patch.dict('django.conf.settings.FEATURES', {"ENABLE_CREATOR_GROUP": True}): |
483 | | - organizations = get_allowed_organizations_for_libraries(self.user) |
484 | | - # Assert that the method returned the expected value |
485 | | - self.assertEqual(organizations, ['org1', 'org2']) |
| 491 | + # Assert that correct org values are returned based on course creator state |
| 492 | + for course_creator_state in CourseCreator.STATES: |
| 493 | + course_creator.state = course_creator_state |
| 494 | + organizations = get_allowed_organizations_for_libraries(self.user) |
| 495 | + if course_creator_state != CourseCreator.GRANTED: |
| 496 | + self.assertEqual(organizations, []) |
| 497 | + else: |
| 498 | + self.assertEqual(organizations, ['org1', 'org2']) |
486 | 499 | with mock.patch.dict( |
487 | 500 | 'django.conf.settings.FEATURES', |
488 | 501 | {"ENABLE_ORGANIZATION_STAFF_ACCESS_FOR_CONTENT_LIBRARIES": True} |
|
0 commit comments