diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 41702b64df..101533a467 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -29,7 +29,7 @@ from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.inheritance import own_metadata from opaque_keys.edx.keys import UsageKey -from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation +from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation, CourseLocator from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.xml_exporter import export_to_xml from xmodule.modulestore.xml_importer import import_from_xml, perform_xlint @@ -46,6 +46,7 @@ from student.models import CourseEnrollment from student.roles import CourseCreatorRole, CourseInstructorRole from opaque_keys import InvalidKeyError from contentstore.tests.utils import get_url +from course_action_state.models import CourseRerunState, CourseRerunUIStateManager TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE) @@ -1561,6 +1562,107 @@ class MetadataSaveTestCase(ContentStoreTestCase): pass +class RerunCourseTest(ContentStoreTestCase): + """ + Tests for Rerunning a course via the view handler + """ + def setUp(self): + super(RerunCourseTest, self).setUp() + self.destination_course_data = { + 'org': 'MITx', + 'number': '111', + 'display_name': 'Robot Super Course', + 'run': '2013_Spring' + } + self.destination_course_key = _get_course_id(self.destination_course_data) + + def post_rerun_request(self, source_course_key, response_code=200): + """Create and send an ajax post for the rerun request""" + + # create data to post + rerun_course_data = {'source_course_key': unicode(source_course_key)} + rerun_course_data.update(self.destination_course_data) + + # post the request + course_url = get_url('course_handler', self.destination_course_key, 'course_key_string') + response = self.client.ajax_post(course_url, rerun_course_data) + + # verify response + self.assertEqual(response.status_code, response_code) + if response_code == 200: + self.assertNotIn('ErrMsg', parse_json(response)) + + def create_course_listing_html(self, course_key): + """Creates html fragment that is created for the given course_key in the course listing section""" + return '