[PATCH 2 of 2 saem_ref] [eac] Replace ark's / by - in filename as well

Philippe Pepiot philippe.pepiot at logilab.fr
Mon Mar 13 15:38:47 CET 2017


On 03/09/2017 05:53 PM, Sylvain Thenault wrote:
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1489075398 -3600
> #      Thu Mar 09 17:03:18 2017 +0100
> # Node ID 57549b98e7a18612acbbcbba60517326db711971
> # Parent  4a0aabd394ca9b0d374e510223b37eefc733af84
> [eac] Replace ark's / by - in filename as well
>
> for consistency with recordId.

This one was modified in hg (without unrelated hunks), please resend it.

>
> diff --git a/cubicweb_saem_ref/entities/container.py b/cubicweb_saem_ref/entities/container.py
> --- a/cubicweb_saem_ref/entities/container.py
> +++ b/cubicweb_saem_ref/entities/container.py
> @@ -43,16 +43,22 @@ def registration_callback(vreg):
>      vreg.register(IContainer.build_class('Organization'))
>      for etype, parent_relations in org_container_def(vreg.schema):
>          IContained.register_class(vreg, etype, parent_relations)
>      vreg.register(IContainer.build_class('AuthorityRecord'))
>      for etype, parent_relations in authority_record_container_def(vreg.schema):
> +        if etype == 'Activity':
> +            continue
>          IContained.register_class(vreg, etype, parent_relations)
>      vreg.register(IContainer.build_class('ConceptScheme'))
>      for etype, parent_relations in scheme_container_def(vreg.schema):
> +        if etype == 'Activity':
> +            continue
>          if etype == 'Concept':
>              # XXX turn parent_relations to a list to ensure broader_concept is considered first
>              parent_relations = list(parent_relations)
>              parent_relations.insert(0, ('broader_concept', 'subject'))
>          IContained.register_class(vreg, etype, parent_relations)
>      vreg.register(IContainer.build_class('Concept'))
>      for etype, parent_relations in concept_container_def(vreg.schema):
> +        if etype == 'Activity':
> +            continue
>          IContained.register_class(vreg, etype, parent_relations)
> diff --git a/cubicweb_saem_ref/entities/eac.py b/cubicweb_saem_ref/entities/eac.py
> --- a/cubicweb_saem_ref/entities/eac.py
> +++ b/cubicweb_saem_ref/entities/eac.py
> @@ -41,11 +41,11 @@ class AuthorityRecordEACAdapter(eac.Auth
>
>      @property
>      def file_name(self):
>          """Return a file name for the dump."""
>          if self.entity.ark:
> -            name = self.entity.ark.replace("/", "_")
> +            name = self.entity.ark.replace("/", "-")
>              return u'EAC_{0}.xml'.format(name)
>          return super(AuthorityRecordEACAdapter, self).file_name
>
>      def recordid_element(self, control_elt):
>          # export ark in <recordId>
> diff --git a/cubicweb_saem_ref/schema.py b/cubicweb_saem_ref/schema.py
> --- a/cubicweb_saem_ref/schema.py
> +++ b/cubicweb_saem_ref/schema.py
> @@ -282,16 +282,16 @@ class related_concept_scheme(RelationDef
>      description = _('concept schemes used by the agent')
>
>
>  class generated(RelationDefinition):
>      subject = 'Activity'
> -    object = ('Concept', 'ConceptScheme')
> +    object = ('Concept', 'ConceptScheme', 'SEDAArchiveTransfer')
>
>
>  class used(RelationDefinition):
>      subject = 'Activity'
> -    object = ('Concept', 'ConceptScheme')
> +    object = ('Concept', 'ConceptScheme', 'SEDAArchiveTransfer')
>
>
>  # ARK ##########################################################################
>
>  class ark(RelationDefinition):
> diff --git a/test/test_views.py b/test/test_views.py
> --- a/test/test_views.py
> +++ b/test/test_views.py
> @@ -176,11 +176,11 @@ class FuncViewsTC(CubicWebTC):
>          with self.admin_access.web_request() as req:
>              cnx = req.cnx
>              agent = testutils.authority_record(cnx, u'jim')
>              for ark, expected_filename in (
>                  (u"", "EAC_{0}.xml".format(agent.eid)),
> -                (u"ZZZ/4242", "EAC_ZZZ_4242.xml".format(agent.eid)),
> +                (u"ZZZ/4242", "EAC_ZZZ-4242.xml".format(agent.eid)),
>              ):
>                  agent.cw_set(ark=ark)
>                  view = self.vreg['views'].select('eac.export', req, agent.as_rset())
>                  view.set_request_content_type()
>                  self.assertEqual(
> diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
> --- a/test/unittest_hooks.py
> +++ b/test/unittest_hooks.py
> @@ -464,10 +464,20 @@ class EntityLifeCycleTC(CubicWebTC):
>              rset = cnx.execute('Activity X ORDERBY X DESC WHERE X type "modify", X used %(x)s',
>                                 {'x': scheme.eid})
>              self.assertEqual(len(rset), 2)
>              self.assertEqual(rset.get_entity(0, 0).description, 'added in_scheme_object')
>
> +    def test_archive_transfer_create_update(self):
> +        with self.new_access(u'bob').cnx() as cnx:
> +            transfer = testutils.setup_profile(cnx)
> +            cnx.commit()
> +            self._check_create(cnx, transfer.eid, 'created sedaarchivetransfer')
> +            transfer.cw_set(title=u'123')
> +            cnx.commit()
> +            self._check_modification(cnx, transfer.eid,
> +                                     'modified title')
> +
>
>  class SEDAArchiveTransferHooksTC(CubicWebTC):
>
>      def test_profile_deprecated(self):
>          """Test hook deprecating a SEDA Profile upon successor publication."""
>



More information about the saem-devel mailing list