def test_email_authorized(self):
     BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=True)
     # Authorize the course to use email
     cauth = CourseAuthorization(course_id=self.course.id, email_enabled=True)
     cauth.save()
     # Assert that instructor email is enabled for this course
     self.assertTrue(is_bulk_email_feature_enabled(self.course.id))
     # Assert that the URL for the email view is not in the response
     # if this course isn't authorized
     response = self.client.get(self.url)
     self.assertContains(response, self.email_modal_link)
Esempio n. 2
0
    def test_creation_auth_off(self):
        BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=False)
        course_id = CourseKey.from_string('blahx/blah101/ehhhhhhh')
        # Test that course is authorized by default, since auth is turned off
        assert is_bulk_email_feature_enabled(course_id)

        # Use the admin interface to unauthorize the course
        cauth = CourseAuthorization(course_id=course_id, email_enabled=False)
        cauth.save()

        # Now, course should STILL be authorized!
        assert is_bulk_email_feature_enabled(course_id)
Esempio n. 3
0
    def test_course_authorized_feature_off(self):
        BulkEmailFlag.objects.create(enabled=False, require_course_email_auth=True)
        # Authorize the course to use email
        cauth = CourseAuthorization(course_id=self.course.id, email_enabled=True)
        cauth.save()

        # Assert that this course is authorized for instructor email, but the feature is not enabled
        self.assertFalse(is_bulk_email_feature_enabled(self.course.id))
        self.assertTrue(is_bulk_email_enabled_for_course(self.course.id))
        # Assert that the URL for the email view IS NOT in the response
        response = self.client.get(self.url)
        self.assertNotContains(response, self.email_link)
Esempio n. 4
0
 def test_course_authorized_and_on_deny_list(self):
     BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=True)
     # Authorize the course to use email
     cauth = CourseAuthorization(course_id=self.course.id, email_enabled=True)
     cauth.save()
     # Disabled the course to use email
     disabled_course = DisabledCourse(course_id=self.course.id)
     disabled_course.save()
     # Assert that instructor email is disabled for this course
     assert is_bulk_email_disabled_for_course(self.course.id)
     # Assert that the URL for the email view is not in the response
     response = self.client.get(self.url)
     self.assertNotContains(response, self.email_link)
Esempio n. 5
0
def is_bulk_email_enabled_for_course(course_id):
    """
    Arguments:
        course_id: the course id of the course

    Returns:
        bool: True if the Bulk Email feature is enabled for the course
        associated with the course_id; False otherwise
    """
    return CourseAuthorization.instructor_email_enabled(course_id)
Esempio n. 6
0
    def test_creation_auth_on(self):
        BulkEmailFlag.objects.create(enabled=True, require_course_email_auth=True)
        course_id = CourseKey.from_string('abc/123/doremi')
        # Test that course is not authorized by default
        assert not is_bulk_email_feature_enabled(course_id)

        # Authorize
        cauth = CourseAuthorization(course_id=course_id, email_enabled=True)
        cauth.save()
        # Now, course should be authorized
        assert is_bulk_email_feature_enabled(course_id)
        assert str(cauth) == "Course 'abc/123/doremi': Instructor Email Enabled"

        # Unauthorize by explicitly setting email_enabled to False
        cauth.email_enabled = False
        cauth.save()
        # Test that course is now unauthorized
        assert not is_bulk_email_feature_enabled(course_id)
        assert str(cauth) == "Course 'abc/123/doremi': Instructor Email Not Enabled"