[PATCH 1 of 2 eac] [entities] allow export different otherRecordId with same localType

Philippe Pepiot philippe.pepiot at logilab.fr
Fri Feb 24 17:55:36 CET 2017


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1487954743 -3600
#      Fri Feb 24 17:45:43 2017 +0100
# Node ID a7a2ad4e5cf2a4a266897b04defb9dbc90467844
# Parent  14f04db9621e25f9176d59f5af2340347376e15c
# Available At https://hg.logilab.org/review/cubes/eac
#              hg pull https://hg.logilab.org/review/cubes/eac -r a7a2ad4e5cf2
# Tested at: https://jenkins.logilab.org/job/cubicweb-eac/58/
[entities] allow export different otherRecordId with same localType

There is no mention that we should not have two otherRecordId with same
localType in eac-cpf specification.

Related to extranet #12572781

diff --git a/cubicweb_eac/entities.py b/cubicweb_eac/entities.py
--- a/cubicweb_eac/entities.py
+++ b/cubicweb_eac/entities.py
@@ -57,7 +57,8 @@ class AuthorityRecord(AnyEntity):
 
     @property
     def other_record_ids(self):
-        return dict((orec.local_type, orec.value) for orec in self.reverse_eac_other_record_id_of)
+        return sorted([(r.local_type, r.value)
+                       for r in self.reverse_eac_other_record_id_of])
 
 
 class AgentKind(AnyEntity):
@@ -298,7 +299,7 @@ class AuthorityRecordEACAdapter(Abstract
         if record_id is None:
             record_id = text_type(self.entity.eid)
         self.element('recordId', parent=control_elt, text=record_id)
-        for local_type, value in sorted(self.entity.other_record_ids.items()):
+        for local_type, value in self.entity.other_record_ids:
             attrs = {}
             if local_type is not None:
                 attrs['localType'] = local_type
diff --git a/test/test_dataimport.py b/test/test_dataimport.py
--- a/test/test_dataimport.py
+++ b/test/test_dataimport.py
@@ -471,8 +471,8 @@ class EACDataImportTC(CubicWebTC):
             self.assertEqual(record.kind, 'authority')
             self.assertEqual(record.start_date, datetime.date(1800, 1, 1))
             self.assertEqual(record.end_date, datetime.date(2099, 1, 1))
-            self.assertEqual(record.other_record_ids, {None: '1234',
-                                                       'letters': 'ABCD'})
+            self.assertEqual(record.other_record_ids,
+                             [(None, '1234'), ('letters', 'ABCD')])
             address = record.postal_address[0]
             self.assertEqual(address.street, u'1 Esplanade Charles de Gaulle')
             self.assertEqual(address.postalcode, u'33074')



More information about the saem-devel mailing list