Commit 1fdeb061 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[xsd gen] Test and fix export of code list version

It turns out that we weren't handling concept scheme values at all.
parent 6b37740bb6bd
...@@ -353,6 +353,8 @@ def xsd_serialize(value): ...@@ -353,6 +353,8 @@ def xsd_serialize(value):
if value is None: if value is None:
return None return None
if hasattr(value, 'eid'): if hasattr(value, 'eid'):
if value.cw_etype == 'ConceptScheme':
return value.absolute_url()
if value.cw_etype == 'Concept': if value.cw_etype == 'Concept':
return value.labels['en'] return value.labels['en']
if hasattr(value, 'id'): if hasattr(value, 'id'):
......
...@@ -282,6 +282,22 @@ class SEDAXSDExportTC(XmlTestMixin, CubicWebTC): ...@@ -282,6 +282,22 @@ class SEDAXSDExportTC(XmlTestMixin, CubicWebTC):
kwr[0], kwr[0],
[{'name': 'schemeURI', 'fixed': scheme.absolute_url()}]) [{'name': 'schemeURI', 'fixed': scheme.absolute_url()}])
def test_code_list(self):
with self.admin_access.client_cnx() as cnx:
transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
scheme = cnx.create_entity('ConceptScheme', title=u'Keyword Types')
cnx.create_entity('SEDAMimeTypeCodeListVersion',
seda_mime_type_code_list_version_from=transfer,
seda_mime_type_code_list_version_to=scheme)
profile = self.profile_etree(transfer)
mt_clv = self.xpath(profile, '//xs:element[@name="MimeTypeCodeListVersion"]')
self.assertEqual(len(mt_clv), 1)
self.assertEqual(mt_clv[0].attrib, {'name': 'MimeTypeCodeListVersion',
'fixed': scheme.absolute_url(),
'minOccurs': '0'})
# XXX also fix listSchemeURI ?
def profile_etree(self, transfer_entity): def profile_etree(self, transfer_entity):
"""Return etree representation of profile's XSD for the given transfer entity""" """Return etree representation of profile's XSD for the given transfer entity"""
xsd = transfer_entity.cw_adapt_to('SEDA-2.0.xsd').dump() xsd = transfer_entity.cw_adapt_to('SEDA-2.0.xsd').dump()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment