'Export a single AssetMetadata to XML and verify the structure and fields.'

def test_export_single_asset_to_from_xml(self):

    asset_md = self.course_assets[0]
    root = etree.Element('assets')
    asset = etree.SubElement(root, 'asset')
    asset_md.to_xml(asset)
    etree.fromstring(etree.tostring(root), self.xmlparser)
    new_asset_key = self.course_id.make_asset_key('tmp', 'tmp')
    new_asset_md = AssetMetadata(new_asset_key)
    new_asset_md.from_xml(asset)
    for attr in AssetMetadata.XML_ATTRS:
        if (attr in AssetMetadata.XML_ONLY_ATTRS):
            continue
        orig_value = getattr(asset_md, attr)
        new_value = getattr(new_asset_md, attr)
        self.assertEqual(orig_value, new_value)
