Exemplo n.º 1
0
 def test_library_creator_status_settings(self, disable_course,
                                          disable_library, expected_status):
     """
     Ensure that the setting DISABLE_LIBRARY_CREATION overrides DISABLE_COURSE_CREATION as expected.
     """
     _, nostaff_user = self.create_non_staff_authed_user_client()
     with mock.patch("contentstore.views.library.LIBRARIES_ENABLED", True):
         with mock.patch.dict(
                 "django.conf.settings.FEATURES", {
                     "DISABLE_COURSE_CREATION": disable_course,
                     "DISABLE_LIBRARY_CREATION": disable_library
                 }):
             self.assertEqual(get_library_creator_status(nostaff_user),
                              expected_status)
Exemplo n.º 2
0
    def test_library_creator_status_with_no_course_creator_role_and_disabled_nonstaff_course_creation(self):
        """
        Ensure that `DISABLE_COURSE_CREATION` feature works with libraries as well.
        """
        nostaff_client, nostaff_user = self.create_non_staff_authed_user_client()
        self.assertFalse(get_library_creator_status(nostaff_user))

        # To be explicit, this user can GET, but not POST
        get_response = nostaff_client.get_json(LIBRARY_REST_URL)
        post_response = nostaff_client.ajax_post(LIBRARY_REST_URL, {
            'org': 'org', 'library': 'lib', 'display_name': "New Library",
        })
        self.assertEqual(get_response.status_code, 200)
        self.assertEqual(post_response.status_code, 403)
Exemplo n.º 3
0
 def test_library_creator_status_settings(self, disable_course, disable_library, expected_status):
     """
     Ensure that the setting DISABLE_LIBRARY_CREATION overrides DISABLE_COURSE_CREATION as expected.
     """
     _, nostaff_user = self.create_non_staff_authed_user_client()
     with mock.patch("contentstore.views.library.LIBRARIES_ENABLED", True):
         with mock.patch.dict(
             "django.conf.settings.FEATURES",
             {
                 "DISABLE_COURSE_CREATION": disable_course,
                 "DISABLE_LIBRARY_CREATION": disable_library
             }
         ):
             self.assertEqual(get_library_creator_status(nostaff_user), expected_status)
Exemplo n.º 4
0
    def test_library_creator_status_with_no_course_creator_role_and_disabled_nonstaff_course_creation(self):
        """
        Ensure that `DISABLE_COURSE_CREATION` feature works with libraries as well.
        """
        nostaff_client, nostaff_user = self.create_non_staff_authed_user_client()
        self.assertFalse(get_library_creator_status(nostaff_user))

        # To be explicit, this user can GET, but not POST
        get_response = nostaff_client.get_json(LIBRARY_REST_URL)
        post_response = nostaff_client.ajax_post(LIBRARY_REST_URL, {
            'org': 'org', 'library': 'lib', 'display_name': "New Library",
        })
        self.assertEqual(get_response.status_code, 200)
        self.assertEqual(post_response.status_code, 403)
Exemplo n.º 5
0
 def test_library_creator_status_with_no_course_creator_role(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     self.assertEqual(get_library_creator_status(nostaff_user), True)
Exemplo n.º 6
0
 def test_library_creator_status_with_course_creator_role(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     with mock.patch.dict('django.conf.settings.FEATURES',
                          {"ENABLE_CREATOR_GROUP": True}):
         grant_course_creator_status(self.user, nostaff_user)
         self.assertEqual(get_library_creator_status(nostaff_user), True)
Exemplo n.º 7
0
 def test_library_creator_status_with_is_staff_user(self):
     self.assertEqual(get_library_creator_status(self.user), True)
Exemplo n.º 8
0
 def test_library_creator_status_libraries_not_enabled(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     self.assertEqual(get_library_creator_status(nostaff_user), False)
Exemplo n.º 9
0
 def test_library_creator_status_with_no_course_creator_role(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     self.assertEqual(get_library_creator_status(nostaff_user), True)
Exemplo n.º 10
0
 def test_library_creator_status_with_course_creator_role(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     with mock.patch.dict('django.conf.settings.FEATURES', {"ENABLE_CREATOR_GROUP": True}):
         grant_course_creator_status(self.user, nostaff_user)
         self.assertEqual(get_library_creator_status(nostaff_user), True)
Exemplo n.º 11
0
 def test_library_creator_status_with_is_staff_user(self):
     self.assertEqual(get_library_creator_status(self.user), True)
Exemplo n.º 12
0
 def test_library_creator_status_libraries_not_enabled(self):
     _, nostaff_user = self.create_non_staff_authed_user_client()
     self.assertEqual(get_library_creator_status(nostaff_user), False)