[PATCH 3 of 3 saem] [entities] Don't copy activities on clone

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Dec 14 07:58:43 CET 2017


this series breaks CI, sending a V2


On 13/12/2017 09:31, Sylvain Thenault wrote:
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1513153645 -3600
> #      Wed Dec 13 09:27:25 2017 +0100
> # Node ID 17740642a454e7c8236395626bd8ada7b8559a53
> # Parent  d29e9194daad16f4a916e93563815a5297dd4758
> # Available At http://hg.logilab.org/review/cubes/saem_ref
> #              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 17740642a454
> [entities] Don't copy activities on clone
>
> In that purpose add `used` and `generated` relation to the clone adapter's
> skiprtypes, skipping 'Actvity' entity types isn't enough (may need more
> exploration to understand why and if this is desired...).
>
> diff --git a/cubicweb_saem_ref/entities/seda.py b/cubicweb_saem_ref/entities/seda.py
> --- a/cubicweb_saem_ref/entities/seda.py
> +++ b/cubicweb_saem_ref/entities/seda.py
> @@ -55,11 +55,11 @@ def agency_id(self, agency):
>      return None if agency.agency is None else 'ark:/' + agency.agency.ark
>  
>  
>  SEDAArchiveTransferIClonableAdapter.__select__ &= is_in_state('published')
>  SEDAArchiveTransferIClonableAdapter.rtype = 'new_version_of'
> -SEDAArchiveTransferIClonableAdapter.skiprtypes += ('clone_of',)
> +SEDAArchiveTransferIClonableAdapter.skiprtypes += ('clone_of', 'used', 'generated')
>  
>  
>  class SEDAArchiveTransfer(SEDAArchiveTransfer):
>      SEDAArchiveTransfer.fetch_attrs.append('ark')
>  
> diff --git a/test/unittest_entities_container.py b/test/unittest_entities_container.py
> --- a/test/unittest_entities_container.py
> +++ b/test/unittest_entities_container.py
> @@ -101,10 +101,15 @@ class TreeTC(CubicWebTC):
>              # have been copied (but other parts of the test live in the seda
>              # cube)
>              self.assertEqual(clone.ark_naa[0].eid, transfer.ark_naa[0].eid)
>              self.assertEqual(len(clone.reverse_use_profile), 0)
>  
> +            # Ensure activites are not copied
> +            self.assertEqual(len(clone.reverse_generated), 1)
> +            self.assertEqual(len(clone.reverse_used), 1)
> +            self.assertNotEqual(clone.reverse_used[0].start, transfer.reverse_used[-1].start)
> +
>              # Ensure data object is cloned through data_object_reference_id and
>              # container relation is properly handled
>              bdo_clone = cnx.execute('Any MAX(X) WHERE X is SEDABinaryDataObject').one()
>              self.assertNotEqual(bdo_clone.eid, bdo.eid)
>              bdo.cw_clear_all_caches()
>

-- 
Sylvain Thénault, LOGILAB, Paris (01.45.32.03.12) - Toulouse (05.62.17.16.42)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
CubicWeb, the semantic web framework:    http://www.cubicweb.org



More information about the saem-devel mailing list