[PATCH eac] Replace PostalAddress from addressbook by AgentAddress schema

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Thu Sep 5 16:19:18 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1567614949 -7200
#      Wed Sep 04 18:35:49 2019 +0200
# Node ID 48b96846a01e960bf8f5896477e1123698895c1c
# Parent  fde7d0a19cefdaf4cb5978c46904945f0420837a
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 48b96846a01e
Replace PostalAddress from addressbook by AgentAddress schema

PostalAddress was removed because of the structure of the EAC addressLine
tag that has no rigorous indications of how populate the different
attributes of PostalAddress.

A new entity was created, which just keep a concatenated string of
the differents values in the addressLine tags.

It also allow to free the cubicweb_eac cube of the import of the
addressbook cube.

diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/__pkginfo__.py
--- a/cubicweb_eac/__pkginfo__.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/__pkginfo__.py	Wed Sep 04 18:35:49 2019 +0200
@@ -18,7 +18,6 @@
     'six': '>= 1.4.0',
     'cubicweb-prov': '>= 0.4.0',
     'cubicweb-skos': '>= 1.3.0',
-    'cubicweb-addressbook': None,
     'cubicweb-compound': '>= 0.6.0',
     'python-dateutil': None,
 }
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Wed Sep 04 18:35:49 2019 +0200
@@ -36,13 +36,13 @@
 
 from cubicweb_skos import to_unicode
 
-from cubicweb_eac import TYPE_MAPPING, ADDRESS_MAPPING, MAINTENANCETYPE_MAPPING
+from cubicweb_eac import TYPE_MAPPING, MAINTENANCETYPE_MAPPING
 
 
 TYPE_MAPPING = TYPE_MAPPING.copy()
 TYPE_MAPPING['human'] = u'person'
 
-ETYPES_ORDER_HINT = ('AgentKind', 'PhoneNumber', 'PostalAddress', 'AuthorityRecord',
+ETYPES_ORDER_HINT = ('AgentKind', 'AgentAddress', 'AuthorityRecord',
                      'Convention', 'AgentPlace', 'PlaceEntry',
                      'Mandate', 'LegalStatus', 'History', 'HistoricalEvent', 'Structure',
                      'AgentFunction', 'Occupation', 'GeneralContext', 'AssociationRelation',
@@ -802,7 +802,10 @@
         for address in self._elem_findall(elem, 'eac:address'):
             for extentity in self.build_address(address):
                 if extentity.values:
-                    values['place_address'] = set([extentity.extid])
+                    addresses = [extentity.extid]
+                    if 'agent_address' in values:
+                        addresses.append(values['agent_address'])
+                    values['agent_address'] = set(addresses)
                     yield extentity
         place = ExtEntity('AgentPlace', self._gen_extid(), values)
         for child in self.build_place_entry(elem):
@@ -825,15 +828,15 @@
             yield ExtEntity('PlaceEntry', self._gen_extid(), values)
 
     def build_address(self, elem):
-        """Build `PostalAddress`s external entity"""
-        address_entity = {}
+        """Build `AgentAddress`s external entity"""
+        address_lines = []
         for line in self._elem_findall(elem, 'eac:addressLine'):
-            if 'localType' in line.attrib:
-                attr = dict(ADDRESS_MAPPING).get(line.attrib['localType'])
-                if attr:
-                    address_entity.setdefault(attr, set()).add(
-                        text_type(line.text))
-        yield ExtEntity('PostalAddress', self._gen_extid(), address_entity)
+            if line.text and line.text.strip():
+                address_lines.append(text_type(line.text.strip()))
+        if address_lines:
+            values = {'raw_address':
+                      {u"\n".join(address_lines)}}
+        yield ExtEntity('AgentAddress', self._gen_extid(), values)
 
     @relate_to_record_through('AgentFunction', 'function_agent')
     @filter_empty
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/entities.py
--- a/cubicweb_eac/entities.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/entities.py	Wed Sep 04 18:35:49 2019 +0200
@@ -30,7 +30,7 @@
 from cubicweb.entities import AnyEntity, fetch_config
 from cubicweb.view import EntityAdapter
 
-from cubicweb_eac import TYPE_MAPPING, ADDRESS_MAPPING, MAINTENANCETYPE_MAPPING
+from cubicweb_eac import TYPE_MAPPING, MAINTENANCETYPE_MAPPING
 
 
 class DateRelationMixin(object):
@@ -617,8 +617,9 @@
                 value = getattr(place_entry, attr)
                 if value:
                     place_entry_elt.attrib[eac_name] = text_type(value)
-        for address in place.place_address:
-            self.address_element(address, place_elt)
+        # Remove support of address_element
+        # The new format do not provide indications on
+        # street, postalcode and city
         return place_elt
 
     @add_descriptive_note
@@ -717,12 +718,6 @@
             maintenance_event_elt.append(agent_type_elt)
             maintenance_event_elt.append(self.element('agent'))
 
-    def address_element(self, address, place_elt):
-        address_elt = self.element('address', parent=place_elt)
-        for eac_name, attr in ADDRESS_MAPPING:
-            self._elt_text_from_attr('addressLine', address, attr,
-                                     attributes={'localType': eac_name}, parent=address_elt)
-
     # helper methods for lxml
 
     def _elt_text_from_attr(self, tag_name, entity, attr_name, parent=None, attributes=None):
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/i18n/en.po
--- a/cubicweb_eac/i18n/en.po	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/i18n/en.po	Wed Sep 04 18:35:49 2019 +0200
@@ -290,10 +290,10 @@
 msgstr "Occupations"
 
 msgctxt "inlined:AgentPlace.place_address.subject"
-msgid "PostalAddress"
+msgid "AgentAddress"
 msgstr ""
 
-msgid "Qualified relation between an AuthorityRecord and a PostalAddress"
+msgid "Qualified relation between an AuthorityRecord and a AgentAddress"
 msgstr ""
 
 msgid "Reference text coming from an authority"
@@ -571,7 +571,7 @@
 msgstr ""
 
 msgctxt "inlined:AgentPlace.place_address.subject"
-msgid "add a PostalAddress"
+msgid "add a AgentAddress"
 msgstr ""
 
 msgid "add a Structure"
@@ -1303,7 +1303,7 @@
 msgid "place_address_object"
 msgstr "place"
 
-msgctxt "PostalAddress"
+msgctxt "AgentAddress"
 msgid "place_address_object"
 msgstr ""
 
@@ -1321,18 +1321,18 @@
 msgid "place_agent_object"
 msgstr ""
 
-msgid "postal_address"
+msgid "agent_address"
 msgstr "postal address"
 
 msgctxt "AuthorityRecord"
-msgid "postal_address"
+msgid "agent_address"
 msgstr ""
 
-msgid "postal_address_object"
+msgid "agent_address_object"
 msgstr "agent"
 
-msgctxt "PostalAddress"
-msgid "postal_address_object"
+msgctxt "AgentAddress"
+msgid "agent_address_object"
 msgstr "agent"
 
 msgid "record_id"
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/i18n/fr.po
--- a/cubicweb_eac/i18n/fr.po	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/i18n/fr.po	Wed Sep 04 18:35:49 2019 +0200
@@ -302,10 +302,10 @@
 msgstr "Professions"
 
 msgctxt "inlined:AgentPlace.place_address.subject"
-msgid "PostalAddress"
+msgid "AgentAddress"
 msgstr "Adresse postale"
 
-msgid "Qualified relation between an AuthorityRecord and a PostalAddress"
+msgid "Qualified relation between an AuthorityRecord and a AgentAddress"
 msgstr "Relation qualifiée entre une notice et une adresse postale"
 
 msgid "Reference text coming from an authority"
@@ -592,7 +592,7 @@
 msgstr "ajouter une profession"
 
 msgctxt "inlined:AgentPlace.place_address.subject"
-msgid "add a PostalAddress"
+msgid "add a AgentAddress"
 msgstr "ajouter une adresse postale"
 
 msgid "add a Structure"
@@ -1351,7 +1351,7 @@
 msgid "place_address_object"
 msgstr "lieu"
 
-msgctxt "PostalAddress"
+msgctxt "AgentAddress"
 msgid "place_address_object"
 msgstr ""
 
@@ -1369,18 +1369,18 @@
 msgid "place_agent_object"
 msgstr ""
 
-msgid "postal_address"
+msgid "agent_address"
 msgstr "adresse postale"
 
 msgctxt "AuthorityRecord"
-msgid "postal_address"
+msgid "agent_address"
 msgstr ""
 
-msgid "postal_address_object"
+msgid "agent_address_object"
 msgstr "notice"
 
-msgctxt "PostalAddress"
-msgid "postal_address_object"
+msgctxt "AgentAddress"
+msgid "agent_address_object"
 msgstr ""
 
 msgid "record_id"
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/migration/0.9.0_Any.py
--- a/cubicweb_eac/migration/0.9.0_Any.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/migration/0.9.0_Any.py	Wed Sep 04 18:35:49 2019 +0200
@@ -6,6 +6,7 @@
 add_entity_type('PlaceEntry')
 add_entity_type('IdentityRelation')
 add_entity_type('FamilyRelation')
+add_entity_type('AgentAddress')
 
 # Attributes to update
 add_attribute('EACResourceRelation', 'xml_attributes')
@@ -62,3 +63,9 @@
                         'AuthorityRecord')
 
 sync_schema_props_perms('AuthorityRecord')
+
+rql("""
+INSERT AgentAddress A: X agent_address A, A raw_address R
+WHERE X is AgentPlace, X place_address P, P raw_address R""")
+drop_entity_type('PostalAddress')
+remove_cube('addressbook')
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/schema.py
--- a/cubicweb_eac/schema.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/schema.py	Wed Sep 04 18:35:49 2019 +0200
@@ -22,15 +22,9 @@
 from cubicweb import _
 from cubicweb.schema import RRQLExpression, RQLVocabularyConstraint
 
-from cubes.addressbook import schema as addressbook
 from cubicweb_prov.schema import Activity
 
 
-# Customization of addressbook schema.
-for attrname in ('street', 'city', 'postalcode'):
-    addressbook.PostalAddress.get_relation(attrname).cardinality = '?1'
-
-
 def xml_wrap(cls):
     """Class decorator adding an `xml_wrap` attribute to an EntityType."""
     desc = _('XML elements not contained in EAC-CPF namespace')
@@ -178,18 +172,21 @@
 
 @with_items
 class AgentPlace(EntityType):
-    """Qualified relation between an AuthorityRecord and a PostalAddress"""
+    """Qualified relation between an AuthorityRecord and a AgentAddress"""
     role = String(description=_('contextual role the address has in relation '
                                 'with the agent (e.g. "home")'),
                   internationalizable=True)
-    __unique_together__ = [('role', 'place_agent', 'place_address')]
 
 
-class place_address(RelationDefinition):
+class AgentAddress(EntityType):
+    raw_address = String(description=_("Attribute containing concatenated <addressLine> values"),
+                         indexed=True, fulltextindexed=True)
+
+
+class agent_address(RelationDefinition):
     subject = 'AgentPlace'
-    object = 'PostalAddress'
-    cardinality = '?1'
-    inlined = True
+    object = 'AgentAddress'
+    cardinality = '*?'
     composite = 'subject'
     fulltext_container = 'subject'
 
@@ -204,7 +201,7 @@
 
 
 class postal_address(ComputedRelation):
-    rule = 'P place_agent S, P place_address O'
+    rule = 'P place_agent S, P agent_address O'
 
 
 class AgentKind(EntityType):
diff -r fde7d0a19cef -r 48b96846a01e cubicweb_eac/views.py
--- a/cubicweb_eac/views.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/cubicweb_eac/views.py	Wed Sep 04 18:35:49 2019 +0200
@@ -119,9 +119,9 @@
 pvs.tag_object_of(('*', 'has_citation', 'Citation'), 'hidden')
 
 # AgentPlace
-afs.tag_subject_of(('AgentPlace', 'place_address', 'PostalAddress'),
+afs.tag_subject_of(('AgentPlace', 'agent_address', 'AgentAddress'),
                    'main', 'inlined')
-afs.tag_object_of(('AgentPlace', 'place_address', 'PostalAddress'), 'main', 'hidden')
+afs.tag_object_of(('AgentPlace', 'agent_address', 'AgentAddress'), 'main', 'hidden')
 
 # AgentFunction
 affk.set_field_kwargs('AgentFunction', 'name', widget=fw.TextInput({'size': 80}))
diff -r fde7d0a19cef -r 48b96846a01e debian/control
--- a/debian/control	Wed Sep 04 18:25:45 2019 +0200
+++ b/debian/control	Wed Sep 04 18:35:49 2019 +0200
@@ -16,7 +16,6 @@
  python-six (>= 1.4.0),
  cubicweb-prov (>= 0.4.0),
  cubicweb-skos,
- cubicweb-addressbook,
  cubicweb-compound (>= 0.6.0),
  ${python:Depends},
  ${misc:Depends},
diff -r fde7d0a19cef -r 48b96846a01e test/data/FRAD033_EAC_00001_simplified.xml
--- a/test/data/FRAD033_EAC_00001_simplified.xml	Wed Sep 04 18:25:45 2019 +0200
+++ b/test/data/FRAD033_EAC_00001_simplified.xml	Wed Sep 04 18:35:49 2019 +0200
@@ -155,7 +155,7 @@
 	</nameEntry>
 
 	<useDates>
-	  <dateSet>
+	  <dateSet>
 	    <dateRange localType="open">
 	    <fromDate
 		standardDate="1949">1949
@@ -175,7 +175,7 @@
 	    <toDate>open
 	    </toDate>
 	  </dateRange>
-	  </dateSet>
+	  </dateSet>
 	  </useDates>	  
 	</nameEntryParallel>
     </identity>
@@ -201,10 +201,16 @@
           <placeRole>siege</placeRole>
           <placeEntry vocabularySource="http://catalogue.bnf.fr/ark:/12148/cb152418385">Bordeaux (Gironde, France)</placeEntry>
           <address>
-              <addressLine localType="StreetName">1 Esplanade Charles de Gaulle</addressLine>
-              <addressLine localType="PostCode">33074</addressLine>
-              <addressLine localType="CityName"> Bordeaux Cedex</addressLine>
+              <addressLine localType="voie">1 Esplanade Charles de Gaulle</addressLine>
+              <addressLine localType="postalcode">33074</addressLine>
+              <addressLine localType="city"> Bordeaux Cedex</addressLine>
+          </address>
+	  <address>
+              <addressLine localType="voie">Test voie</addressLine>
+              <addressLine localType="postalcode">Test postalcode</addressLine>
+              <addressLine localType="city">test cité</addressLine>
          </address>
+  
         <!-- L'élément <placeEntry> est un élément d'indexation. Il y a un problème dans l'export ICA-AtoM : les informations textuelles doivent être contenues dans <descriptiveNote> -->
       </place>
       <place>
@@ -255,11 +261,11 @@
         </occupation>
       </occupations>
 
-      <structureOrGenealogy><p>Pour accomplir ses missions ...</p>
-      <citation>L'élément Citation à fournir un lien vers un document externe comme un
-               organigramme ou un arbre généalogique. Pour une présentation plus simple, sous forme
-               de texte, on peut utiliser un ou plusieurs élém.
-      </citation>
+      <structureOrGenealogy><p>Pour accomplir ses missions ...</p>
+      <citation>L'élément Citation à fournir un lien vers un document externe comme un
+               organigramme ou un arbre généalogique. Pour une présentation plus simple, sous forme
+               de texte, on peut utiliser un ou plusieurs élém.
+      </citation>
     </structureOrGenealogy>
 
       <!--empty structureOrGenealogy-->
@@ -364,7 +370,7 @@
           </dateRange>
           <objectXMLWrap><gloups>hips</gloups></objectXMLWrap>
 	</cpfRelation>
-
+
       <cpfRelation cpfRelationType="family" xlink:href="whatever" xlink:type="simple">
           <relationEntry>CG32</relationEntry>
           <dateRange>
@@ -441,32 +447,32 @@
 	  </p>
 	</descriptiveNote>
       </functionRelation>
-      <functionRelation
-            xlink:href="ONLY_XLINK">
-          <dateRange>
-          <fromDate standardDate="1922">1922</fromDate>
-          <toDate standardDate="2001">2001</toDate>
-          </dateRange>
-          <relationEntry>Some relation entry
-          </relationEntry>
-          <descriptiveNote>
-            <p>Some description
-            </p>
-          </descriptiveNote>
-      </functionRelation>
-      <functionRelation
-            functionRelationType="ONLY_RELATION_TYPE">
-          <dateRange>
-          <fromDate standardDate="1922">1922</fromDate>
-          <toDate standardDate="2001">2001</toDate>
-          </dateRange>
-          <relationEntry>Some relation entry
-          </relationEntry>
-          <descriptiveNote>
-            <p>Some description
-            </p>
-          </descriptiveNote>
-      </functionRelation>
+      <functionRelation
+            xlink:href="ONLY_XLINK">
+          <dateRange>
+          <fromDate standardDate="1922">1922</fromDate>
+          <toDate standardDate="2001">2001</toDate>
+          </dateRange>
+          <relationEntry>Some relation entry
+          </relationEntry>
+          <descriptiveNote>
+            <p>Some description
+            </p>
+          </descriptiveNote>
+      </functionRelation>
+      <functionRelation
+            functionRelationType="ONLY_RELATION_TYPE">
+          <dateRange>
+          <fromDate standardDate="1922">1922</fromDate>
+          <toDate standardDate="2001">2001</toDate>
+          </dateRange>
+          <relationEntry>Some relation entry
+          </relationEntry>
+          <descriptiveNote>
+            <p>Some description
+            </p>
+          </descriptiveNote>
+      </functionRelation>
       
     </relations>
 
diff -r fde7d0a19cef -r 48b96846a01e test/export-roundtrip.rst
--- a/test/export-roundtrip.rst	Wed Sep 04 18:25:45 2019 +0200
+++ b/test/export-roundtrip.rst	Wed Sep 04 18:35:49 2019 +0200
@@ -80,11 +80,6 @@
             <place>
               <placeRole>siege</placeRole>
               <placeEntry vocabularySource="http://catalogue.bnf.fr/ark:/12148/cb152418385">Bordeaux (Gironde, France)</placeEntry>
-              <address>
-                <addressLine localType="StreetName">1 Esplanade Charles de Gaulle</addressLine>
-                <addressLine localType="PostCode">33074</addressLine>
-                <addressLine localType="CityName"> Bordeaux Cedex</addressLine>
-              </address>
             </place>
           </places>
           <functions>
diff -r fde7d0a19cef -r 48b96846a01e test/export-simple.rst
--- a/test/export-simple.rst	Wed Sep 04 18:25:45 2019 +0200
+++ b/test/export-simple.rst	Wed Sep 04 18:35:49 2019 +0200
@@ -5,20 +5,14 @@
 
     >>> from cubicweb import Binary
     >>> record = testutils.authority_record(cnx, u'666', u'Charlie')
-    >>> home_addr = cnx.create_entity(
-    ...     'PostalAddress', street=u'Place du Capitole',
-    ...     postalcode=u'31000', city=u'Toulouse')
     >>> place_entry1 = cnx.create_entity('PlaceEntry', name=u'1')
     >>> place1 = cnx.create_entity(
     ...     'AgentPlace', role=u'home', place_agent=record,
-    ...     place_address=home_addr, place_entry_relation=place_entry1)
-    >>> work_addr = cnx.create_entity(
-    ...     'PostalAddress', street=u'104 bd L.-A. Blanqui',
-    ...     postalcode=u'75013', city=u'Paris')
+    ...     place_entry_relation=place_entry1)
     >>> place_entry2 = cnx.create_entity('PlaceEntry', name=u'2')
     >>> place2 = cnx.create_entity(
     ...     'AgentPlace', role=u'work', place_agent=record,
-    ...   place_address=work_addr, place_entry_relation=place_entry2)
+    ...     place_entry_relation=place_entry2)
     >>> uri = cnx.create_entity('ExternalUri', uri=u'http://www.logilab.fr')
     >>> resource_relation = cnx.create_entity(
     ...     'EACResourceRelation', resource_relation_resource=uri,
@@ -60,20 +54,10 @@
             <place>
               <placeRole>home</placeRole>
               <placeEntry>1</placeEntry>
-              <address>
-                <addressLine localType="StreetName">Place du Capitole</addressLine>
-                <addressLine localType="PostCode">31000</addressLine>
-                <addressLine localType="CityName">Toulouse</addressLine>
-              </address>
             </place>
             <place>
               <placeRole>work</placeRole>
               <placeEntry>2</placeEntry>
-              <address>
-                <addressLine localType="StreetName">104 bd L.-A. Blanqui</addressLine>
-                <addressLine localType="PostCode">75013</addressLine>
-                <addressLine localType="CityName">Paris</addressLine>
-              </address>
             </place>
           </places>
         </description>
diff -r fde7d0a19cef -r 48b96846a01e test/test_dataimport.py
--- a/test/test_dataimport.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/test/test_dataimport.py	Wed Sep 04 18:35:49 2019 +0200
@@ -94,7 +94,7 @@
         return importer.external_entities()
 
     def test_parse_FRAD033_EAC_00001(self):
-        _gen_extid = map(str, (x for x in count() if x not in (2, 38))).next
+        _gen_extid = map(str, (x for x in count() if x not in (2, 39))).next
         expected = [
             ('EACOtherRecordId', _gen_extid(),
              {'eac_other_record_id_of': set(['authorityrecord-FRAD033_EAC_00001']),
@@ -243,17 +243,17 @@
              {'parts': set([u'BK\n\t  '])
               },
              ),
-            ('PostalAddress', _gen_extid(),
-             {'street': set([u'1 Esplanade Charles de Gaulle']),
-              'postalcode': set([u'33074']),
-              'city': set([u' Bordeaux Cedex']),
-              },
+            ('AgentAddress', _gen_extid(),
+             {'raw_address': [u'1 Esplanade Charles de Gaulle\n33074\n Bordeaux Cedex']},
+             ),
+            ('AgentAddress', _gen_extid(),
+             {'raw_address': [u'Test voie\nTest postalcode\ntest cit\xe9']},
              ),
             ('AgentPlace', _gen_extid(),
              {'role': set([u'siege']),
               'place_agent': set(['authorityrecord-FRAD033_EAC_00001']),
-              'place_entry_relation': set(['25']),
-              'place_address': set(['23']),
+              'place_entry_relation': set(['26']),
+              'agent_address': set(['23', '24']),
               },
              ),
             ('PlaceEntry', _gen_extid(),
@@ -263,7 +263,7 @@
              ),
             ('AgentPlace', _gen_extid(),
              {'place_agent': set(['authorityrecord-FRAD033_EAC_00001']),
-              'place_entry_relation': set(['27']),
+              'place_entry_relation': set(['28']),
               'role': set([u'domicile']),
               },
              ),
@@ -277,7 +277,7 @@
             ('AgentPlace', _gen_extid(),
              {'place_agent': set(['authorityrecord-FRAD033_EAC_00001']),
               'role': set([u'dodo']),
-              'place_entry_relation': set(['29']),
+              'place_entry_relation': set(['30']),
               },
              ),
             ('PlaceEntry', _gen_extid(),
@@ -286,7 +286,7 @@
              ),
             ('LegalStatus', _gen_extid(),
              {'term': set([u'Collectivité territoriale']),
-              'date_relation': set(['31']),
+              'date_relation': set(['32']),
               'description': set([u'Description du statut']),
               'description_format': set([u'text/plain']),
               'legal_status_agent': set(['authorityrecord-FRAD033_EAC_00001']),
@@ -307,8 +307,8 @@
              ),
             ('History', _gen_extid(),
              {'abstract': set([u'Test of an abstract element']),
-              'has_citation': set(['39', '40']),
-              'has_event': set(['34', '36']),
+              'has_citation': set(['40', '41']),
+              'has_event': set(['35', '37']),
               'text': set(["\n".join((
                   u'<p xmlns="urn:isbn:1-931666-33-4" '
                   u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
@@ -330,7 +330,7 @@
               },
              ),
             ('HistoricalEvent', _gen_extid(),
-             {'date_relation': set(['35']),
+             {'date_relation': set(['36']),
               'event': [u'Left Mer and moved to the mainland.\n\t      '
                         u'Worked at various jobs including canecutter\n\t      '
                         u'and railway labourer.\n\t      '],
@@ -342,7 +342,7 @@
               },
              ),
             ('HistoricalEvent', _gen_extid(),
-             {'date_relation': set(['37']),
+             {'date_relation': set(['38']),
               'event': set([u'Union representative, Townsville-\n\t      '
                             u'Mount Isa rail construction project.\n\t      ']),
               },
@@ -366,7 +366,7 @@
                                   u'xmlns:xlink="http://www.w3.org/1999/xlink">Pour accomplir '
                                   u'ses missions ...</p>']),
               'description_format': set([u'text/html']),
-              'has_citation': set(['42']),
+              'has_citation': set(['43']),
               'structure_agent': set(['authorityrecord-FRAD033_EAC_00001']),
               },
              ),
@@ -408,11 +408,11 @@
              ),
             ('Occupation', _gen_extid(),
              {'term': set([u'Réunioniste']),
-              'date_relation': set(['47']),
+              'date_relation': set(['48']),
               'description': set([u'Organisation des réunions ...']),
               'description_format': set([u'text/plain']),
               'occupation_agent': set(['authorityrecord-FRAD033_EAC_00001']),
-              'has_citation': set(['48']),
+              'has_citation': set(['49']),
               'equivalent_concept': set(['http://pifgadget.com']),
               },
              ),
@@ -431,7 +431,7 @@
                               u'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                               u'xmlns:xlink="http://www.w3.org/1999/xlink">very famous</p>']),
               'content_format': set([u'text/html']),
-              'has_citation': set(['50']),
+              'has_citation': set(['51']),
               'general_context_of': set(['authorityrecord-FRAD033_EAC_00001']),
               }
              ),
@@ -447,7 +447,7 @@
             ('HierarchicalRelation', _gen_extid(),
              {'entry': set([u"Gironde. Conseil général. Direction de l'administration et de "
                             u"la sécurité juridique"]),
-              'date_relation': set(['52']),
+              'date_relation': set(['53']),
               'description': set([u'Coucou']),
               'description_format': set([u'text/plain']),
               'hierarchical_parent': set(['CG33-DIRADSJ']),
@@ -473,7 +473,7 @@
             ('ChronologicalRelation', _gen_extid(),
              {'chronological_predecessor': set(['whatever']),
               'chronological_successor': set(['authorityrecord-FRAD033_EAC_00001']),
-              'date_relation': set(['54']),
+              'date_relation': set(['55']),
               'entry': set([u'CG32']),
               },
              ),
@@ -486,7 +486,7 @@
             ('ChronologicalRelation', _gen_extid(),
              {'chronological_predecessor': set(['authorityrecord-FRAD033_EAC_00001']),
               'chronological_successor': set(['/dev/null']),
-              'date_relation': set(['56']),
+              'date_relation': set(['57']),
               'xml_wrap': set(['<gloups xmlns="urn:isbn:1-931666-33-4"'
                                u' xmlns:xsi="http://www.w3.org/2001/XML'
                                u'Schema-instance" xmlns:xlink="http://'
@@ -500,7 +500,7 @@
               },
              ),
             ('IdentityRelation', _gen_extid(),
-             {'date_relation': ['58'],
+             {'date_relation': ['59'],
               'entry': [u'Trash'],
               'identity_from': ['authorityrecord-FRAD033_EAC_00001'],
               'identity_to': ['/dev/null'],
@@ -514,7 +514,7 @@
               },
              ),
             ('FamilyRelation', _gen_extid(),
-             {'date_relation': ['60'],
+             {'date_relation': ['61'],
               'entry': [u'CG32'],
               'family_from': ['authorityrecord-FRAD033_EAC_00001'],
               'family_to': ['whatever']}
@@ -532,7 +532,7 @@
              ),
             ('EACResourceRelation', _gen_extid(),
              {'agent_role': set([u'creatorOf']),
-              'date_relation': set(['63']),
+              'date_relation': set(['64']),
               'xml_attributes': set([u'{"{http://www.w3.org/1999/xlink}actuate": "onRequest", '
                                      u'"{http://www.w3.org/1999/xlink}show": "new", '
                                      u'"{http://www.w3.org/1999/xlink}type": "simple"}']),
@@ -595,7 +595,7 @@
                                   'and abolishment of schools.\n\t  </p>']),
               'r_type': set([u'controls']),
               'description_format': set([u'text/html']),
-              'date_relation': set(['66']),
+              'date_relation': set(['67']),
               'relation_entry': set([u'Establishment and abolishment\n\tof schools\n\t']),
               'xml_attributes': set([u'{}'])
               },
@@ -617,7 +617,7 @@
               'description_format': set([u'text/html']),
               'relation_entry': set([u'Some relation entry\n          ']),
               'xml_attributes': set([u'{}']),
-              'date_relation': ['68'],
+              'date_relation': ['69'],
               },
              ),
             ('DateEntity', _gen_extid(),
@@ -637,7 +637,7 @@
               'description_format': set([u'text/html']),
               'relation_entry': set([u'Some relation entry\n          ']),
               'xml_attributes': set([u'{}']),
-              'date_relation': ['70'],
+              'date_relation': ['71'],
               },
              ),
             ('DateEntity', _gen_extid(),
@@ -715,8 +715,8 @@
                           'languageUsed': set([186, 193]),
                           'localControl': set([54]),
                           'source': set([76]),  # empty.
-                          'structureOrGenealogy': set([266]),  # empty.
-                          'biogHist': set([326, 329]),  # empty.
+                          'structureOrGenealogy': set([271]),  # empty.
+                          'biogHist': set([331, 334]),  # empty.
                           })
 
     def check_order_entities(self, entities, expected):
@@ -850,7 +850,7 @@
                                cwuri=u'http://data.culture.fr/thesaurus/page/ark:/67717/T1-1074')
             cnx.commit()
             created, updated = testutils.eac_import(cnx, fpath)
-            self.assertEqual(len(created), 80)
+            self.assertEqual(len(created), 81)
             self.assertEqual(updated, set())
             rset = cnx.find('AuthorityRecord', isni=u'22330001300016')
             self.assertEqual(len(rset), 1)
@@ -860,10 +860,12 @@
             self.assertEqual(record.end_date, datetime.date(2099, 1, 1))
             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')
-            self.assertEqual(address.city, u' Bordeaux Cedex')
+(??)            address = record.postal_address[0]
+(??)            self.assertEqual(address.street, u'1 Esplanade Charles de Gaulle')
+(??)            self.assertEqual(address.postalcode, u'33074')
+(??)            self.assertEqual(address.city, u' Bordeaux Cedex')
+(??)            self.assertEqual(address.raw_address,
+(??)                             u'1 Esplanade Charles de Gaulle\n33074\n Bordeaux Cedex')
             rset = cnx.execute("""
                  Any R,N WHERE P place_agent A, A eid %(eid)s,
                  P role R, P place_entry_relation E, E name N""", {
diff -r fde7d0a19cef -r 48b96846a01e test/test_schema.py
--- a/test/test_schema.py	Wed Sep 04 18:25:45 2019 +0200
+++ b/test/test_schema.py	Wed Sep 04 18:35:49 2019 +0200
@@ -39,14 +39,14 @@
     assertValidationError = assertValidationError
 
     def test_postaladdress_no_required(self):
-        """Make sure a PostalAddress can be "empty" (useful in data import
+        """Make sure a AgentAddress can be "empty" (useful in data import
         context).
         """
         with self.admin_access.cnx() as cnx:
             ar = testutils.authority_record(cnx, u'T-04', u'test')
             cnx.create_entity('AgentPlace',
                               place_agent=ar,
-                              place_address=cnx.create_entity('PostalAddress'))
+                              agent_address=cnx.create_entity('AgentAddress'))
             cnx.commit()
             # No assert, just make sure db integrity checks pass.
 
@@ -130,7 +130,7 @@
                           ('simple_name_relation', 'object'): set(['ParallelNames'])},
             'Occupation': {('occupation_agent', 'subject'): set(['AuthorityRecord'])},
             'ParallelNames': {('parallel_names_of', 'subject'): set(['AuthorityRecord'])},
-            'PostalAddress': {('place_address', 'object'): set(['AgentPlace'])},
+            'AgentAddress': {('agent_address', 'object'): set(['AgentPlace'])},
             'Structure': {('structure_agent', 'subject'): set(['AuthorityRecord'])},
         }
         struct = dict(
@@ -142,7 +142,8 @@
         graph = AuthorityRecordGraph(self.schema)
         structure = graph.parent_structure('AuthorityRecord')
         opts = optional_relations(self.schema, structure)
-        expected = {'NameEntry': set([('name_entry_for', 'subject'),
+        expected = {'AgentAddress': set([('agent_address', 'object')]),
+                    'NameEntry': set([('name_entry_for', 'subject'),
                                       ('simple_name_relation', 'object')])}
         self.assertEqual(opts, expected)
 


More information about the saem-devel mailing list