[PATCH 1 of 3 saem v4] [hooks] Update list of relations that should not be logged

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Jul 19 14:36:35 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1500451225 -7200
#      Wed Jul 19 10:00:25 2017 +0200
# Node ID 367be17338ab94ae4dfc913869e73f105fe35825
# Parent  ea255b3ad3fd252b2e7b46c518aaa97919c3b11e
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 367be17338ab
[hooks] Update list of relations that should not be logged

Drop no more used 'mirror_of' relation and add other
functional-but-considered-meta relation (ie that do not impact data exported as
OAI).

In test, rename a variable from agent to organization_unit since this is what it
is.

Related to extranet #29296087

diff --git a/cubicweb_saem_ref/hooks.py b/cubicweb_saem_ref/hooks.py
--- a/cubicweb_saem_ref/hooks.py
+++ b/cubicweb_saem_ref/hooks.py
@@ -30,13 +30,17 @@ from cubicweb.server import hook
 from cubicweb.hooks import metadata
 
 from cubes.skos.hooks import ReplaceExternalUriByEntityHook
 
 
-# skip relation involved in the logging itself, or mirroring relation
-IGNORE_RELATIONS = set(('used', 'generated', 'associated_with', 'mirror_of',
-                        'primary_email'))
+# skip relations involved in the logging itself and some others that should not
+# be logged nor impact container's modification date
+IGNORE_RELATIONS = set(('used', 'generated', 'associated_with',
+                        'primary_email',
+                        'use_authorityrecord', 'related_concept_scheme', 'use_profile',
+                        'new_version_of', 'clone_of',
+                        'scheme_entity_type', 'scheme_relation_type'))
 
 
 @objectify_predicate
 def contained_relation(cls, req, rtype, eidfrom, eidto, **kwargs):
     """Predicate that returns True for relation from/to a container or contained entity.
diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
--- a/test/unittest_hooks.py
+++ b/test/unittest_hooks.py
@@ -124,17 +124,15 @@ class SAEMRefHooksTC(CubicWebTC):
             self.assertMDNow(transfer)
             transfer.cw_adapt_to('IWorkflowable').fire_transition('publish')
             cnx.commit()
             self.resetMD(cnx, transfer)
             # edit link from root to an entity which is not part of the container
-            # XXX that shouldn't change anything for this special relation
-            agent = testutils.organization_unit(
+            organization_unit = testutils.organization_unit(
                 cnx, u'marcel', archival_roles=['deposit'])
-            transfer.cw_set(reverse_use_profile=agent)
+            transfer.cw_set(reverse_use_profile=organization_unit)
             cnx.commit()
-            self.assertMDNow(transfer)
-            self.resetMD(cnx, transfer)
+            self.assertEqual(transfer.modification_date, YESTERDAY)
 
     def test_externaluri_to_concept(self):
         with self.admin_access.repo_cnx() as cnx:
             # create some authority record and related objects
             agent = testutils.authority_record(cnx, u'bob')


More information about the saem-devel mailing list