[profile gen] Export URL for keyword reference content
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 30 Mar 2017 17:22:31 +0200
changeset 2565 3da29cc2d6c8
parent 2564 dd0fa3ba2760
child 2566 ea3da4a88df1
[profile gen] Export URL for keyword reference content not text. Consistently with SEDA 1/0.2 export.
cubicweb_seda/entities/profile_generation.py
test/test_profile_generation.py
--- a/cubicweb_seda/entities/profile_generation.py	Thu Mar 30 17:21:52 2017 +0200
+++ b/cubicweb_seda/entities/profile_generation.py	Thu Mar 30 17:22:31 2017 +0200
@@ -538,7 +538,12 @@
                 if attrname in ('id', 'href') or attrname.startswith(('list', 'scheme')):
                     parent_element = self._rng_attribute_parent(occ, None, profile_element)
                     self._rng_attribute(occ.target, parent_element)
-        fixed_value = serialize(value, self.cwuri_url)
+        # special case for KeywordReference content, the only known case where we want URL instead
+        # of label of its concept value
+        if value is not None and xselement.local_name == 'KeywordReference':
+            fixed_value = self.cwuri_url(value)
+        else:
+            fixed_value = serialize(value, self.cwuri_url)
         if fixed_value is not None:
             if _internal_reference(value):
                 profile_element.attrib[self.qname('a:defaultValue')] = fixed_value
--- a/test/test_profile_generation.py	Thu Mar 30 17:21:52 2017 +0200
+++ b/test/test_profile_generation.py	Thu Mar 30 17:22:31 2017 +0200
@@ -495,7 +495,7 @@
             kwr = self.get_element(profile, 'KeywordReference')
             self.assertElementDefinition(kwr, {'name': 'KeywordReference',
                                                'type': 'xsd:token',
-                                               'fixed': 'theme'})
+                                               'fixed': kw_type.cwuri})
             self.assertXSDAttributes(
                 kwr,
                 [{'name': 'schemeURI', 'fixed': scheme.cwuri}])