[PATCH eac] Add PlaceEntry entity to implement <placeEntry>

Frank Bessou frank.bessou at logilab.fr
Thu Aug 22 17:56:01 CEST 2019



On 22/08/2019 16:48, Guillaume Vandevelde wrote:
> # HG changeset patch
> # User Guillaume Vandevelde <gvandevelde at logilab.fr>
> # Date 1564058212 -7200
> #      Thu Jul 25 14:36:52 2019 +0200
> # Node ID 05f02f514f5a37dcc2ba7981a7bb5821cacb5401
> # Parent  f0f7b8fae35c0c855179c87bd35ab08f0cd3643e
> # Available At http://hg.logilab.org/review/cubes/eac
> #              hg pull http://hg.logilab.org/review/cubes/eac -r 05f02f514f5a
> Add PlaceEntry entity to implement <placeEntry>
> 
> diff -r f0f7b8fae35c -r 05f02f514f5a cubicweb_eac/dataimport.py
> --- a/cubicweb_eac/dataimport.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/cubicweb_eac/dataimport.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -183,9 +183,14 @@
>               for extentity in func(self, elem):
>                   if extentity.etype == etype:
>                       for child in build_child(elem):
> -                        extentity.values.setdefault(
> -                            relation, set()).add(child.extid)
> -                        yield child
> +                        if (etype, relation, child.etype) in (
> +                                ('AgentPlace', 'place_entry_relation', 'ExternalUri'), ):

It's strange to handle a very specific case in this generic function.

It would be nice to explain why this condition is necessary and if it 
really is needed, it may be better to call build_place_entry directly in 
build_place.

> +                            # must return the ExternalUri to be created for PlaceEntry
> +                            yield child
> +                        else:
> +                            extentity.values.setdefault(
> +                                relation, set()).add(child.extid)
> +                            yield child
>                   yield extentity
>           return wrapper
>       return decorator
> @@ -195,6 +200,8 @@
>   add_events_for = partial(add_child_for, relation='has_event', builder='build_event')
>   add_dates_for = partial(add_child_for, relation='date_relation',
>                           builder='build_date_entry')
> +add_places_for = partial(add_child_for, relation='place_entry_relation',
> +                         builder='build_place_entry')

places --> place_entry/place_entries ? :)

>   
>   
>   def require_tag(tagname):
> @@ -594,6 +601,7 @@
>       @relate_to_record_through('LegalStatus', 'legal_status_agent')
>       @filter_empty
>       @add_citations_for('LegalStatus')
> +    @add_places_for('LegalStatus')
>       @add_items_for('LegalStatus')
>       @add_dates_for('LegalStatus')
>       @equivalent_concept('eac:term', 'LegalStatus')
> @@ -612,6 +620,7 @@
>       @relate_to_record_through('Mandate', 'mandate_agent')
>       @filter_empty
>       @add_citations_for('Mandate')
> +    @add_places_for('Mandate')
>       @add_items_for('Mandate')
>       @add_dates_for('Mandate')
>       @equivalent_concept('eac:term', 'Mandate')
> @@ -663,6 +672,7 @@
>               yield ExtEntity('History', self._gen_extid(), values)
>   
>       @add_dates_for('HistoricalEvent')
> +    @add_places_for('HistoricalEvent')
>       @filter_none
>       @filter_empty
>       @elem_maybe_none
> @@ -691,18 +701,15 @@
>       @relate_to_record_through('AgentPlace', 'place_agent')
>       @filter_empty
>       @add_citations_for('AgentPlace')
> +    @add_places_for('AgentPlace')
>       @add_dates_for('AgentPlace')
>       @add_items_for('AgentPlace')
> -    @equivalent_concept('eac:placeEntry', 'AgentPlace')
>       def build_place(self, elem):
>           """Build a AgentPlace external entity"""
>           values = {}
>           role = self._elem_find(elem, 'eac:placeRole')
>           if role is not None:
>               values['role'] = set([text_type(role.text)])
> -        entry = self._elem_find(elem, 'eac:placeEntry')
> -        if entry is not None:
> -            values['name'] = set([text_type(entry.text)])


Explain in commit message that the AgentPlace's name is replaced by a 
PlaceEntry.


>           for address in self._elem_findall(elem, 'eac:address'):
>               for extentity in self.build_address(address):
>                   if extentity.values:
> @@ -710,6 +717,20 @@
>                       yield extentity
>           yield ExtEntity('AgentPlace', self._gen_extid(), values)
>   
> +    @filter_none
> +    @filter_empty
> +    @elem_maybe_none
> +    @equivalent_concept('eac:placeEntry', 'PlaceEntry')


Maybe some of these are not required ?


> +    def build_place_entry(self, elem):
> +        for entry in self._elem_findall(elem, 'eac:placeEntry'):
> +            values = {'place': set([text_type(entry.text)])}


place --> name ?

Will read the next part tomorrow :)


> +            values.update(self.values_from_attrib(
> +                entry,
> +                (('local_type', 'localType'),
> +                 ('longitude', 'longitude'),
> +                 ('latitude', 'latitude'))))
> +            yield ExtEntity('PlaceEntry', self._gen_extid(), values)
> +
>       def build_address(self, elem):
>           """Build `PostalAddress`s external entity"""
>           address_entity = {}
> @@ -724,6 +745,7 @@
>       @relate_to_record_through('AgentFunction', 'function_agent')
>       @filter_empty
>       @add_citations_for('AgentFunction')
> +    @add_places_for('AgentFunction')
>       @add_dates_for('AgentFunction')
>       @add_items_for('AgentFunction')
>       @equivalent_concept('eac:term', 'AgentFunction')
> @@ -738,6 +760,7 @@
>       @relate_to_record_through('Occupation', 'occupation_agent')
>       @filter_empty
>       @add_citations_for('Occupation')
> +    @add_places_for('Occupation')
>       @add_items_for('Occupation')
>       @add_dates_for('Occupation')
>       @equivalent_concept('eac:term', 'Occupation')
> @@ -834,6 +857,9 @@
>       @add_dates_for('AssociationRelation')
>       @add_dates_for('ChronologicalRelation')
>       @add_dates_for('HierarchicalRelation')
> +    @add_places_for('AssociationRelation')
> +    @add_places_for('ChronologicalRelation')
> +    @add_places_for('HierarchicalRelation')
>       def build_relation(self, elem):
>           """Build a relation between records external entity (with proper type)."""
>           relationship = elem.attrib.get('cpfRelationType')
> @@ -885,6 +911,7 @@
>           values.update(self.parse_tag_description(elem))
>           yield ExtEntity(etype, self._gen_extid(), values)
>   
> +    @add_places_for('EACFunctionRelation')
>       @add_dates_for('EACFunctionRelation')
>       @add_xml_wrap_for('EACFunctionRelation')
>       def build_function_relation(self, elem):
> @@ -917,6 +944,7 @@
>           values.update({'xml_attributes': set([text_type(attributes)])})
>           yield ExtEntity('EACFunctionRelation', self._gen_extid(), values)
>   
> +    @add_places_for('EACResourceRelation')
>       @add_dates_for('EACResourceRelation')
>       @add_xml_wrap_for('EACResourceRelation')
>       def build_resource_relation(self, elem):
> diff -r f0f7b8fae35c -r 05f02f514f5a cubicweb_eac/entities.py
> --- a/cubicweb_eac/entities.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/cubicweb_eac/entities.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -193,7 +193,7 @@
>   
>   class AgentPlace(DateRelationMixin, SameAsMixIn, AnyEntity):
>       __regid__ = 'AgentPlace'
> -    fetch_attrs, cw_fetch_order = fetch_config(('name', 'role'))
> +    fetch_attrs, cw_fetch_order = fetch_config(('role', ))
>   
>   
>   class AgentFunction(DateRelationMixin, SameAsMixIn, AnyEntity):
> @@ -245,6 +245,12 @@
>                                                   'parts'))
>   
>   
> +class PlaceEntry(SameAsMixIn, AnyEntity):
> +    __regid__ = 'PlaceEntry'
> +    fetch_attrs, cw_fetch_order = fetch_config(('place', 'latitude',
> +                                                'longitude', 'local_type'))
> +
> +
>   # XML export
>   
>   def substitute_xml_prefix(prefix_name, namespaces):
> @@ -546,10 +552,22 @@
>       @add_citation
>       def place_element(self, place):
>           place_elt = self.element('place')
> -        for attr, eac_name in [('role', 'placeRole'), ('name', 'placeEntry')]:
> -            eac_elt = self._elt_text_from_attr(eac_name, place, attr, parent=place_elt)
> -            if eac_elt is not None and eac_name == 'placeEntry' and place.equivalent_concept:
> -                eac_elt.attrib['vocabularySource'] = self.cwuri_url(place.equivalent_concept[0])
> +        for attr, eac_name in [('role', 'placeRole')]:
> +            self._elt_text_from_attr(eac_name, place, attr, parent=place_elt)
> +        for place_entry in place.place_entry_relation:
> +            place_entry_elt = self._elt_text_from_attr('placeEntry', place_entry, 'place',
> +                                                       parent=place_elt)
> +            if place_entry_elt is not None:
> +                if place_entry.equivalent_concept:
> +                    place_entry_elt.attrib['vocabularySource'] = self.cwuri_url(
> +                        place_entry.equivalent_concept[0]
> +                    )
> +                for attr, eac_name in (('longitude', 'longitude'),
> +                                       ('latitude', 'latitude'),
> +                                       ('local_type', 'localType')):
> +                    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)
>           return place_elt
> diff -r f0f7b8fae35c -r 05f02f514f5a cubicweb_eac/migration/0.9.0_Any.py
> --- a/cubicweb_eac/migration/0.9.0_Any.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/cubicweb_eac/migration/0.9.0_Any.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -2,6 +2,7 @@
>   add_entity_type('Convention')
>   add_entity_type('EACFunctionRelation')
>   add_entity_type('DateEntity')
> +add_entity_type('PlaceEntry')
>   
>   # Attributes to update
>   add_attribute('EACResourceRelation', 'xml_attributes')
> @@ -9,6 +10,20 @@
>   
>   add_attribute('History', 'abstract')
>   
> +# migrate AgentPlace
> +
> +for agent_eid, name, exturi_eid, in cnx.execute(
> +        'Any X, N, E WHERE X is AgentPlace, X name N, X equivalent_concept E?'):
> +    cnx.create_entity('PlaceEntry', place=name,
> +                      reverse_place_entry_relation=agent_eid,
> +                      equivalent_concept=exturi_eid)
> +
> +drop_attribute('AgentPlace', 'name')
> +drop_relation_definition('AgentPlace', 'equivalent_concept', ('ExternalUri', 'Concept'))
> +
> +cnx.commit()
> +
> +
>   for attrib in ('language', 'preferred_form',
>                  'alternative_form', 'authorized_form',
>                  'script_code'):
> @@ -32,3 +47,4 @@
>                 'AgentFunction', 'LegalStatus', 'AgentPlace', 'Structure'):
>       add_attribute(etype, 'items')
>       
> +add_relation_type('place_entry_relation')
> diff -r f0f7b8fae35c -r 05f02f514f5a cubicweb_eac/schema.py
> --- a/cubicweb_eac/schema.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/cubicweb_eac/schema.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -16,7 +16,7 @@
>   """cubicweb-eac schema"""
>   
>   from yams.buildobjs import (EntityType, RelationDefinition, String, Date, Bytes,
> -                            RichString, ComputedRelation)
> +                            RichString, Float, ComputedRelation)
>   from yams.constraints import BoundaryConstraint, Attribute
>   
>   from cubicweb import _
> @@ -99,6 +99,24 @@
>       fulltext_container = 'subject'
>   
>   
> +class PlaceEntry(EntityType):
> +    place = String(fulltextindexed=True)
> +    local_type = String(fulltextindexed=True)
> +    latitude = Float()
> +    longitude = Float()
> +
> +
> +class place_entry_relation(RelationDefinition):
> +    subject = ('HierarchicalRelation', 'HistoricalEvent',
> +               'ChronologicalRelation', 'AssociationRelation',
> +               'AgentFunction', 'EACFunctionRelation', 'LegalStatus',
> +               'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation')
> +    object = 'PlaceEntry'
> +    cardinality = '*1'
> +    composite = 'subject'
> +    fulltext_container = 'subject'
> +
> +
>   class EACOtherRecordId(EntityType):
>       value = String(required=True, fulltextindexed=True, indexed=True)
>       local_type = String(indexed=True)
> @@ -134,9 +152,6 @@
>   @with_items
>   class AgentPlace(EntityType):
>       """Qualified relation between an AuthorityRecord and a PostalAddress"""
> -    name = String(fulltextindexed=True,
> -                  description=_('encoded information about the address (e.g. '
> -                                '"Paris, France")'))
>       role = String(description=_('contextual role the address has in relation '
>                                   'with the agent (e.g. "home")'),
>                     internationalizable=True)
> @@ -485,8 +500,8 @@
>   
>   
>   class equivalent_concept(RelationDefinition):
> -    subject = ('Mandate', 'LegalStatus', 'AgentFunction', 'AgentPlace',
> -               'Occupation')
> +    subject = ('Mandate', 'LegalStatus', 'AgentFunction',
> +               'Occupation', 'PlaceEntry')
>       object = ('ExternalUri', 'Concept')
>       constraints = [RQLVocabularyConstraint('S vocabulary_source SC, O in_scheme SC')]
>       cardinality = '?*'
> diff -r f0f7b8fae35c -r 05f02f514f5a test/data/FRAD033_EAC_00001_simplified.xml
> --- a/test/data/FRAD033_EAC_00001_simplified.xml	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/data/FRAD033_EAC_00001_simplified.xml	Thu Jul 25 14:36:52 2019 +0200
> @@ -137,7 +137,7 @@
>         </place>
>         <place>
>             <placeRole>domicile</placeRole>
> -          <placeEntry>Toulouse (France)</placeEntry>
> +          <placeEntry latitude="43.60426" longitude="1.44367" localType="other">Toulouse (France)</placeEntry>
>         </place>
>         <places>
>             <place>
> diff -r f0f7b8fae35c -r 05f02f514f5a test/data/FRAD033_EAC_00001_simplified_export.xml
> --- a/test/data/FRAD033_EAC_00001_simplified_export.xml	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/data/FRAD033_EAC_00001_simplified_export.xml	Thu Jul 25 14:36:52 2019 +0200
> @@ -86,7 +86,7 @@
>           </place>
>           <place>
>               <placeRole>domicile</placeRole>
> -            <placeEntry>Toulouse (France)</placeEntry>
> +            <placeEntry longitude="1.44367" latitude="43.60426" localType="other">Toulouse (France)</placeEntry>
>           </place>
>         </places>
>   
> diff -r f0f7b8fae35c -r 05f02f514f5a test/export-roundtrip.rst
> --- a/test/export-roundtrip.rst	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/export-roundtrip.rst	Thu Jul 25 14:36:52 2019 +0200
> @@ -70,6 +70,14 @@
>             </existDates>
>             <places>
>               <place>
> +              <placeRole>dodo</placeRole>
> +              <placeEntry>Lit</placeEntry>
> +            </place>
> +            <place>
> +              <placeRole>domicile</placeRole>
> +              <placeEntry longitude="1.44367" latitude="43.60426" localType="other">Toulouse (France)</placeEntry>
> +            </place>
> +            <place>
>                 <placeRole>siege</placeRole>
>                 <placeEntry vocabularySource="http://catalogue.bnf.fr/ark:/12148/cb152418385">Bordeaux (Gironde, France)</placeEntry>
>                 <address>
> @@ -78,14 +86,6 @@
>                   <addressLine localType="CityName"> Bordeaux Cedex</addressLine>
>                 </address>
>               </place>
> -            <place>
> -              <placeRole>dodo</placeRole>
> -              <placeEntry>Lit</placeEntry>
> -            </place>
> -            <place>
> -              <placeRole>domicile</placeRole>
> -              <placeEntry>Toulouse (France)</placeEntry>
> -            </place>
>             </places>
>             <functions>
>               <function>
> diff -r f0f7b8fae35c -r 05f02f514f5a test/export-simple.rst
> --- a/test/export-simple.rst	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/export-simple.rst	Thu Jul 25 14:36:52 2019 +0200
> @@ -8,15 +8,17 @@
>       >>> home_addr = cnx.create_entity(
>       ...     'PostalAddress', street=u'Place du Capitole',
>       ...     postalcode=u'31000', city=u'Toulouse')
> +    >>> place_entry1 = cnx.create_entity('PlaceEntry', place=u'1')
>       >>> place1 = cnx.create_entity(
> -    ...     'AgentPlace', name=u'1', role=u'home', place_agent=record,
> -    ...     place_address=home_addr)
> +    ...     '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_entry2 = cnx.create_entity('PlaceEntry', place=u'2')
>       >>> place2 = cnx.create_entity(
> -    ...     'AgentPlace', name=u'2', role=u'work', place_agent=record,
> -    ...   place_address=work_addr)
> +    ...     'AgentPlace', role=u'work', place_agent=record,
> +    ...   place_address=work_addr, 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,
> diff -r f0f7b8fae35c -r 05f02f514f5a test/test_dataimport.py
> --- a/test/test_dataimport.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/test_dataimport.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -84,7 +84,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, 25))).next
> +        _gen_extid = map(str, (x for x in count() if x not in (2, 28))).next
>           expected = [
>               ('AuthorityRecord', 'FRAD033_EAC_00001',
>                {'isni': set([u'22330001300016']),
> @@ -196,28 +196,43 @@
>                 },
>                ),
>               ('AgentPlace', _gen_extid(),
> -             {'name': set([u'Bordeaux (Gironde, France)']),
> -              'role': set([u'siege']),
> +             {'role': set([u'siege']),
>                 'place_agent': set(['FRAD033_EAC_00001']),
> +              'place_entry_relation': set(['15']),
>                 'place_address': set(['13']),
> -              'equivalent_concept': set(['http://catalogue.bnf.fr/ark:/12148/cb152418385']),
> +             },
> +            ),
> +            ('PlaceEntry', _gen_extid(),
> +             {'place': set([u'Bordeaux (Gironde, France)']),
> +              'equivalent_concept': set(['http://catalogue.bnf.fr/ark:/12148/cb152418385'])
>                 },
>                ),
>               ('AgentPlace', _gen_extid(),
> -             {'name': set([u'Toulouse (France)']),
> -              'place_agent': set(['FRAD033_EAC_00001']),
> +             {'place_agent': set(['FRAD033_EAC_00001']),
> +              'place_entry_relation': set(['17']),
>                 'role': set([u'domicile']),
>                 },
>                ),
> +            ('PlaceEntry', _gen_extid(),
> +             {'latitude': set([u'43.60426']),
> +              'local_type': set([u'other']),
> +              'longitude': set([u'1.44367']),
> +              'place': set([u'Toulouse (France)']), # noqa
> +             },
> +            ),
>               ('AgentPlace', _gen_extid(),
> -             {'name': set([u'Lit']),
> -              'place_agent': set(['FRAD033_EAC_00001']),
> +             {'place_agent': set(['FRAD033_EAC_00001']),
>                 'role': set([u'dodo']),
> +              'place_entry_relation': set(['19']),
> +             },
> +            ),
> +            ('PlaceEntry', _gen_extid(),
> +             {'place': set([u'Lit']), # noqa
>                 },
>                ),
>               ('LegalStatus', _gen_extid(),
>                {'term': set([u'Collectivité territoriale']),
> -              'date_relation': set(['18']),
> +              'date_relation': set(['21']),
>                 'description': set([u'Description du statut']),
>                 'description_format': set([u'text/plain']),
>                 'legal_status_agent': set(['FRAD033_EAC_00001']),
> @@ -257,8 +272,8 @@
>                               u'      (1931)\n\t    </li>\n\t  </ul>\n      ']),
>                 'items_format': set([u'text/html']),
>                 'history_agent': set(['FRAD033_EAC_00001']),
> -              'has_citation': set(['21', '22']),
> -              'has_event': set(['24', '23']),
> +              'has_citation': set(['24', '25']),
> +              'has_event': set(['26', '27']),
>                 },
>                ),
>               ('Citation', _gen_extid(),
> @@ -319,11 +334,11 @@
>                ),
>               ('Occupation', _gen_extid(),
>                {'term': set([u'Réunioniste']),
> -              'date_relation': set(['31']),
> +              'date_relation': set(['34']),
>                 'description': set([u'Organisation des réunions ...']),
>                 'description_format': set([u'text/plain']),
>                 'occupation_agent': set(['FRAD033_EAC_00001']),
> -              'has_citation': set(['32']),
> +              'has_citation': set(['35']),
>                 'equivalent_concept': set(['http://pifgadget.com']),
>                 },
>                ),
> @@ -341,7 +356,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(['34']),
> +              'has_citation': set(['37']),
>                 'general_context_of': set(['FRAD033_EAC_00001']),
>                 }
>                ),
> @@ -357,7 +372,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(['36']),
> +              'date_relation': set(['39']),
>                 'description': set([u'Coucou']),
>                 'description_format': set([u'text/plain']),
>                 'hierarchical_parent': set(['CG33-DIRADSJ']),
> @@ -382,7 +397,7 @@
>               ('ChronologicalRelation', _gen_extid(),
>                {'chronological_predecessor': set(['whatever']),
>                 'chronological_successor': set(['FRAD033_EAC_00001']),
> -              'date_relation': set(['38']),
> +              'date_relation': set(['41']),
>                 'entry': set([u'CG32']),
>                 },
>                ),
> @@ -394,7 +409,7 @@
>               ('ChronologicalRelation', _gen_extid(),
>                {'chronological_predecessor': set(['FRAD033_EAC_00001']),
>                 'chronological_successor': set(['/dev/null']),
> -              'date_relation': set(['40']),
> +              'date_relation': set(['43']),
>                 '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://'
> @@ -413,7 +428,7 @@
>                ),
>               ('EACResourceRelation', _gen_extid(),
>                {'agent_role': set([u'creatorOf']),
> -              'date_relation': set(['43']),
> +              'date_relation': set(['46']),
>                 '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"}']),
> @@ -475,7 +490,7 @@
>                                     'and abolishment of schools.\n\t  </p>']),
>                 'r_type': set([u'controls']),
>                 'description_format': set([u'text/html']),
> -              'date_relation': set(['46']),
> +              'date_relation': set(['49']),
>                 'relation_entry': set([u'Establishment and abolishment\n\tof schools\n\t']),
>                 'xml_attributes': set([u'{}'])
>                 },
> @@ -496,7 +511,7 @@
>                 'description_format': set([u'text/html']),
>                 'relation_entry': set([u'Some relation entry\n          ']),
>                 'xml_attributes': set([u'{}']),
> -              'date_relation': ['48'],
> +              'date_relation': ['51'],
>                 },
>                ),
>               ('DateEntity', _gen_extid(),
> @@ -515,7 +530,7 @@
>                 'description_format': set([u'text/html']),
>                 'relation_entry': set([u'Some relation entry\n          ']),
>                 'xml_attributes': set([u'{}']),
> -              'date_relation': ['50'],
> +              'date_relation': ['53'],
>                 },
>                ),
>               ('DateEntity', _gen_extid(),
> @@ -726,7 +741,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), 60)
> +            self.assertEqual(len(created), 63)
>               self.assertEqual(updated, set())
>               rset = cnx.find('AuthorityRecord', isni=u'22330001300016')
>               self.assertEqual(len(rset), 1)
> @@ -740,8 +755,10 @@
>               self.assertEqual(address.street, u'1 Esplanade Charles de Gaulle')
>               self.assertEqual(address.postalcode, u'33074')
>               self.assertEqual(address.city, u' Bordeaux Cedex')
> -            rset = cnx.execute('Any R,N WHERE P place_agent A, A eid %(eid)s, P role R, P name N',
> -                               {'eid': record.eid})
> +            rset = cnx.execute("""
> +                 Any R,N WHERE P place_agent A, A eid %(eid)s,
> +                 P role R, P place_entry_relation E, E place N""", {
> +                     'eid': record.eid})
>               self.assertCountEqual(rset.rows,
>                                     [[u'siege', u'Bordeaux (Gironde, France)'],
>                                      [u'domicile', u'Toulouse (France)'],
> @@ -884,7 +901,7 @@
>                            'Concept')
>           self.assertEqual(functions['environnement'].vocabulary_source[0].eid,
>                            functions['environnement'].equivalent_concept[0].scheme.eid)
> -        place = cnx.find('AgentPlace', role=u'siege').one()
> +        place = cnx.find('PlaceEntry', place=u'Bordeaux (Gironde, France)').one()
>           self.assertEqual(place.equivalent_concept[0].cwuri,
>                            'http://catalogue.bnf.fr/ark:/12148/cb152418385')
>   
> diff -r f0f7b8fae35c -r 05f02f514f5a test/test_schema.py
> --- a/test/test_schema.py	Tue Jul 23 17:08:58 2019 +0200
> +++ b/test/test_schema.py	Thu Jul 25 14:36:52 2019 +0200
> @@ -107,6 +107,10 @@
>                   'HistoricalEvent', 'AgentFunction', 'EACFunctionRelation',
>                   'LegalStatus', 'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation'
>               ])},
> +            'PlaceEntry': {('place_entry_relation', 'object'): set([
> +                'HistoricalEvent', 'AgentFunction', 'EACFunctionRelation',
> +                'LegalStatus', 'Mandate', 'Occupation', 'AgentPlace', 'EACResourceRelation'
> +            ])},
>               'EACFunctionRelation': {('function_relation_agent', 'subject'):
>                                       set(['AuthorityRecord'])},
>               'EACOtherRecordId': {('eac_other_record_id_of', 'subject'):
> 

-- 
Frank Bessou
Logilab         https://www.logilab.fr



More information about the saem-devel mailing list