'Test publishing moves and deletes.'

@patch('xmodule.tabs.CourseTab.from_json', side_effect=mock_tab_from_json)
def test_move_delete(self, _from_json):

    source_course = CourseLocator(org='testx', course='GreekHero', run='run', branch=BRANCH_NAME_DRAFT)
    dest_course = CourseLocator(org='testx', course='GreekHero', run='run', branch=BRANCH_NAME_PUBLISHED)
    head = source_course.make_usage_key('course', 'head12345')
    chapter2 = source_course.make_usage_key('chapter', 'chapter2')
    problem1 = source_course.make_usage_key('problem', 'problem1')
    modulestore().copy(self.user_id, source_course, dest_course, [head], [chapter2])
    expected = [BlockKey('course', 'head12345'), BlockKey('chapter', 'chapter1'), BlockKey('chapter', 'chapter3'), BlockKey('problem', 'problem1'), BlockKey('problem', 'problem3_2')]
    self._check_course(source_course, dest_course, expected, [BlockKey('chapter', 'chapter2')])
    chapter1 = modulestore().get_item(source_course.make_usage_key('chapter', 'chapter1'))
    chapter3 = modulestore().get_item(source_course.make_usage_key('chapter', 'chapter3'))
    chapter1.children.append(problem1)
    chapter3.children.remove(problem1.map_into_course(chapter3.location.course_key))
    modulestore().delete_item(source_course.make_usage_key('problem', 'problem3_2'), self.user_id)
    modulestore().copy(self.user_id, source_course, dest_course, [head], [chapter2])
    expected = [BlockKey('course', 'head12345'), BlockKey('chapter', 'chapter1'), BlockKey('chapter', 'chapter3'), BlockKey('problem', 'problem1')]
    self._check_course(source_course, dest_course, expected, [BlockKey('chapter', 'chapter2'), BlockKey('problem', 'problem3_2')])
