'Test that copy_from_template\'s "defaults" data is not lost
when blocks are published.'

def test_copy_from_template_publish(self):

    source_library = LibraryFactory.create(modulestore=self.store)
    display_name_expected = 'CUSTOM    Library    Display    Name'
    self.make_block('problem', source_library, display_name=display_name_expected)
    source_library = self.store.get_library(source_library.location.library_key, remove_version=False, remove_branch=False)
    course = CourseFactory.create(modulestore=self.store)
    self.make_block('vertical', course)
    problem_key_in_course = self.store.copy_from_template(source_library.children, dest_key=course.location, user_id=self.user_id)[0]
    for __ in range(2):
        self.store.publish(problem_key_in_course, self.user_id)
        problem_published = self.store.get_item(problem_key_in_course.for_branch(ModuleStoreEnum.BranchName.published))
        self.assertEqual(problem_published.display_name, display_name_expected)
