'Verify that useable library data can be exported.'

def test_library_export(self):

    youtube_id = 'qS4NO9MNC6w'
    library = LibraryFactory.create(modulestore=self.store)
    video_block = ItemFactory.create(category='video', parent_location=library.location, user_id=self.user.id, publish_item=False, youtube_id_1_0=youtube_id)
    name = library.url_name
    lib_key = library.location.library_key
    root_dir = path(tempfile.mkdtemp())
    try:
        export_library_to_xml(self.store, contentstore(), lib_key, root_dir, name)
        lib_xml = lxml.etree.XML(open(((root_dir / name) / LIBRARY_ROOT)).read())
        self.assertEqual(lib_xml.get('org'), lib_key.org)
        self.assertEqual(lib_xml.get('library'), lib_key.library)
        block = lib_xml.find('video')
        self.assertIsNotNone(block)
        self.assertEqual(block.get('url_name'), video_block.url_name)
        video_xml = lxml.etree.XML(open(((((root_dir / name) / 'video') / video_block.url_name) + '.xml')).read())
        self.assertEqual(video_xml.tag, 'video')
        self.assertEqual(video_xml.get('youtube_id_1_0'), youtube_id)
    finally:
        shutil.rmtree((root_dir / name))
