Merge remote-tracking branch 'edx/master' into opaque-keys-merge-master
Conflicts: cms/djangoapps/contentstore/views/item.py cms/djangoapps/contentstore/views/tests/test_container.py cms/djangoapps/contentstore/views/tests/test_tabs.py common/lib/xmodule/xmodule/modulestore/mongo/draft.py lms/djangoapps/certificates/management/commands/gen_cert_report.py lms/djangoapps/certificates/queue.py lms/djangoapps/certificates/views.py lms/djangoapps/courseware/module_render.py lms/djangoapps/courseware/tests/test_module_render.py lms/djangoapps/instructor/views/api.py lms/djangoapps/instructor/views/instructor_dashboard.py lms/djangoapps/instructor/views/legacy.py lms/djangoapps/shoppingcart/tests/test_models.py lms/djangoapps/verify_student/views.py
This commit is contained in:
@@ -11,6 +11,7 @@ from urllib import quote
|
||||
from django.test import TestCase
|
||||
from nose.tools import raises
|
||||
from mock import Mock, patch
|
||||
from django.conf import settings
|
||||
from django.test.utils import override_settings
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
@@ -103,6 +104,7 @@ class TestCommonExceptions400(unittest.TestCase):
|
||||
|
||||
|
||||
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False})
|
||||
class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Ensure that users cannot access endpoints they shouldn't be able to.
|
||||
@@ -1603,6 +1605,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
|
||||
|
||||
|
||||
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False})
|
||||
class TestInstructorSendEmail(ModuleStoreTestCase, LoginEnrollmentTestCase):
|
||||
"""
|
||||
Checks that only instructors have access to email endpoints, and that
|
||||
|
||||
@@ -50,7 +50,7 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase):
|
||||
|
||||
# Select the Email view of the instructor dash
|
||||
session = self.client.session
|
||||
session['idash_mode'] = 'Email'
|
||||
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email'
|
||||
session.save()
|
||||
response = self.client.get(self.url)
|
||||
|
||||
@@ -108,3 +108,38 @@ class TestInstructorDashboardEmailView(ModuleStoreTestCase):
|
||||
# Assert that the URL for the email view is not in the response
|
||||
response = self.client.get(self.url)
|
||||
self.assertFalse(self.email_link in response.content)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True})
|
||||
def test_send_mail_unauthorized(self):
|
||||
""" Test 'Send email' action returns an error if course is not authorized to send email. """
|
||||
|
||||
response = self.client.post(
|
||||
self.url, {
|
||||
'action': 'Send email',
|
||||
'to_option': 'all',
|
||||
'subject': "Welcome to the course!",
|
||||
'message': "Lets start with an introduction!"
|
||||
}
|
||||
)
|
||||
self.assertContains(response, "Email is not enabled for this course.")
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True})
|
||||
def test_send_mail_authorized(self):
|
||||
""" Test 'Send email' action when course is authorized to send email. """
|
||||
|
||||
course_authorization = CourseAuthorization(course_id=self.course.id, email_enabled=True)
|
||||
course_authorization.save()
|
||||
|
||||
session = self.client.session
|
||||
session[u'idash_mode:{0}'.format(self.course.location.course_id)] = 'Email'
|
||||
session.save()
|
||||
|
||||
response = self.client.post(
|
||||
self.url, {
|
||||
'action': 'Send email',
|
||||
'to_option': 'all',
|
||||
'subject': 'Welcome to the course!',
|
||||
'message': 'Lets start with an introduction!',
|
||||
}
|
||||
)
|
||||
self.assertContains(response, "Your email was successfully queued for sending.")
|
||||
|
||||
Reference in New Issue
Block a user