Commit cbc57aae by Zia Fazal

enabled web certs by default

changing default value instead of setting it via fields

fixed broken test

fixed quality violation

following another approach
parent d9751a85
""" """
Test view handler for rerun (and eventually create) Test view handler for rerun (and eventually create)
""" """
import ddt
from django.test.client import RequestFactory from django.test.client import RequestFactory
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from student.roles import CourseInstructorRole, CourseStaffRole from student.roles import CourseInstructorRole, CourseStaffRole
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from contentstore.tests.utils import AjaxEnabledTestClient, parse_json from contentstore.tests.utils import AjaxEnabledTestClient, parse_json
...@@ -13,6 +17,7 @@ from datetime import datetime ...@@ -13,6 +17,7 @@ from datetime import datetime
from xmodule.course_module import CourseFields from xmodule.course_module import CourseFields
@ddt.ddt
class TestCourseListing(ModuleStoreTestCase): class TestCourseListing(ModuleStoreTestCase):
""" """
Unit tests for getting the list of courses for a logged in user Unit tests for getting the list of courses for a logged in user
...@@ -64,3 +69,21 @@ class TestCourseListing(ModuleStoreTestCase): ...@@ -64,3 +69,21 @@ class TestCourseListing(ModuleStoreTestCase):
self.assertEqual(dest_course_key.run, 'copy') self.assertEqual(dest_course_key.run, 'copy')
dest_course = self.store.get_course(dest_course_key) dest_course = self.store.get_course(dest_course_key)
self.assertEqual(dest_course.start, CourseFields.start.default) self.assertEqual(dest_course.start, CourseFields.start.default)
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_newly_created_course_has_web_certs_enabled(self, store):
"""
Tests newly created course has web certs enabled by default.
"""
with modulestore().default_store(store):
response = self.client.ajax_post('/course/', {
'org': 'orgX',
'number': 'CS101',
'display_name': 'Course with web certs enabled',
'run': '2015_T2'
})
self.assertEqual(response.status_code, 200)
data = parse_json(response)
new_course_key = CourseKey.from_string(data['course_key'])
course = self.store.get_course(new_course_key)
self.assertTrue(course.cert_html_view_enabled)
...@@ -741,8 +741,11 @@ def create_new_course_in_store(store, user, org, number, run, fields): ...@@ -741,8 +741,11 @@ def create_new_course_in_store(store, user, org, number, run, fields):
Separated out b/c command line course creation uses this as well as the web interface. Separated out b/c command line course creation uses this as well as the web interface.
""" """
# Set default language from settings # Set default language from settings and enable web certs
fields.update({'language': getattr(settings, 'DEFAULT_COURSE_LANGUAGE', 'en')}) fields.update({
'language': getattr(settings, 'DEFAULT_COURSE_LANGUAGE', 'en'),
'cert_html_view_enabled': True,
})
with modulestore().default_store(store): with modulestore().default_store(store):
# Creating the course raises DuplicateCourseError if an existing course with this org/name is found # Creating the course raises DuplicateCourseError if an existing course with this org/name is found
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment