'Tests that children are automatically refreshed if libraries list changes'

def test_refreshes_children_if_libraries_change(self):

    library2key = self._create_library('org2', 'lib2', 'Library2')
    library2 = modulestore().get_library(library2key)
    (data1, data2) = ('Hello    world!', 'Hello    other    world!')
    ItemFactory.create(category='html', parent_location=self.library.location, user_id=self.user.id, publish_item=False, display_name='Lib1:    HTML    BLock', data=data1)
    ItemFactory.create(category='html', parent_location=library2.location, user_id=self.user.id, publish_item=False, display_name='Lib    2:    HTML    BLock', data=data2)
    with modulestore().default_store(ModuleStoreEnum.Type.split):
        course = CourseFactory.create()
    lc_block = self._add_library_content_block(course, self.lib_key)
    lc_block = self._refresh_children(lc_block)
    self.assertEqual(len(lc_block.children), 1)
    resp = self._update_item(lc_block.location, {'source_library_id': str(library2key)})
    self.assertEqual(resp.status_code, 200)
    lc_block = modulestore().get_item(lc_block.location)
    self.assertEqual(len(lc_block.children), 1)
    html_block = modulestore().get_item(lc_block.children[0])
    self.assertEqual(html_block.data, data2)
