'Test making a course which points to an existing draft and published but not making any changes to either.'

def test_cloned_course(self):

    original_locator = CourseLocator(org='testx', course='wonderful', run='run', branch=BRANCH_NAME_DRAFT)
    original_index = modulestore().get_course_index_info(original_locator)
    new_draft = modulestore().create_course('best', 'leech', 'leech_run', 'leech_master', BRANCH_NAME_DRAFT, versions_dict=original_index['versions'])
    new_draft_locator = new_draft.location
    self.assertRegexpMatches(new_draft_locator.org, 'best')
    self.assertEqual(new_draft.edited_by, 'test@edx.org')
    self.assertEqual(new_draft_locator.version_guid, original_index['versions'][BRANCH_NAME_DRAFT])
    new_index = modulestore().get_course_index_info(new_draft_locator.course_key)
    self.assertEqual(new_index['edited_by'], 'leech_master')
    new_published_locator = new_draft_locator.course_key.for_branch(BRANCH_NAME_PUBLISHED)
    new_published = modulestore().get_course(new_published_locator)
    self.assertEqual(new_published.edited_by, 'test@edx.org')
    self.assertEqual(new_published.location.version_guid, original_index['versions'][BRANCH_NAME_PUBLISHED])
    new_item = modulestore().create_child('leech_master', new_draft.location, 'chapter', fields={'display_name': 'new    chapter'})
    new_draft_locator = new_draft_locator.course_key.version_agnostic()
    new_index = modulestore().get_course_index_info(new_draft_locator)
    self.assertNotEqual(new_index['versions'][BRANCH_NAME_DRAFT], original_index['versions'][BRANCH_NAME_DRAFT])
    new_draft = modulestore().get_course(new_draft_locator)
    self.assertEqual(new_item.edited_by, 'leech_master')
    self.assertNotEqual(new_item.location.version_guid, original_index['versions'][BRANCH_NAME_DRAFT])
    self.assertNotEqual(new_draft.location.version_guid, original_index['versions'][BRANCH_NAME_DRAFT])
    structure_info = modulestore().get_course_history_info(new_draft_locator)
    self.assertEqual(structure_info['edited_by'], 'leech_master')
    original_course = modulestore().get_course(original_locator)
    self.assertEqual(original_course.location.version_guid, original_index['versions'][BRANCH_NAME_DRAFT])
