'Test that xblock export XML format can be parsed preserving field values'

@mock.patch((DISCUSSION_XBLOCK_LOCATION + '.load_definition_xml'))
@ddt.unpack
@ddt.data(*list(_make_attribute_test_cases()))
def test_xblock_export_format(self, id_pair, category_pair, target_pair, patched_load_definition_xml):

    xblock_xml = '\n                                <discussion\n                                                url_name="82bb87a2d22240b1adac2dfcc1e7e5e4"    xblock-family="xblock.v1"\n                                                {id_attr}="{id_value}"\n                                                {category_attr}="{category_value}"\n                                                {target_attr}="{target_value}"\n                                />\n                                '.format(id_attr=id_pair.name, id_value=id_pair.value, category_attr=category_pair.name, category_value=category_pair.value, target_attr=target_pair.name, target_value=target_pair.value)
    node = etree.fromstring(xblock_xml)
    patched_load_definition_xml.side_effect = Exception('Irrelevant')
    block = DiscussionXBlock.parse_xml(node, self.runtime_mock, self.keys, self.id_gen_mock)
    try:
        self.assertEqual(block.discussion_id, id_pair.value)
        self.assertEqual(block.discussion_category, category_pair.value)
        self.assertEqual(block.discussion_target, target_pair.value)
    except AssertionError:
        print xblock_xml
        raise
