'Test that if a library is updated, and the content block is duplicated,
the new block will use the old library version and not the new one.'

def test_duplicated_version(self):

    store = modulestore()
    self.assertEqual(len(self.library.children), 1)
    self.assertEqual(len(self.lc_block.children), 1)
    self.problem.display_name = '--changed    in    library--'
    store.update_item(self.problem, self.user.id)
    ItemFactory.create(category='problem', parent_location=self.library.location, user_id=self.user.id, publish_item=False)
    self.library = store.get_library(self.lib_key)
    self.lc_block = store.get_item(self.lc_block.location)
    self.problem_in_course = store.get_item(self.problem_in_course.location)
    self.assertEqual(len(self.library.children), 2)
    self.assertEqual(len(self.lc_block.children), 1)
    self.assertEqual(self.problem_in_course.location, self.lc_block.children[0])
    self.assertEqual(self.problem_in_course.display_name, self.original_display_name)
    duplicate = store.get_item(_duplicate_item(self.course.location, self.lc_block.location, self.user))
    self.assertEqual(len(duplicate.children), 1)
    self.assertTrue(self.lc_block.source_library_version)
    self.assertEqual(self.lc_block.source_library_version, duplicate.source_library_version)
    problem2_in_course = store.get_item(duplicate.children[0])
    self.assertEqual(problem2_in_course.display_name, self.original_display_name)
