[PATCH 2 of 5 saem_ref v3] Initialize index of sortable related entities on creation

Denis Laxalde denis.laxalde at logilab.fr
Fri Oct 5 17:32:22 CEST 2018


Frank Bessou a écrit :
> # HG changeset patch
> # User Frank Bessou <frank.bessou at logilab.fr>
> # Date 1537868892 -7200
> #      Tue Sep 25 11:48:12 2018 +0200
> # Node ID 6440eeb84824c19eaf1aebb377e6523f35290c69
> # Parent  ffe30bd3c9efba3d958ec331d789bc15387bc164
> # Available At http://hg.logilab.org/review/cubes/saem_ref
> #              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 6440eeb84824
> # EXP-Topic CONSEJIRA-578-584
> Initialize index of sortable related entities on creation
> 
> We will want to display newly created entities at the end of the list so
> we use their eid as index.
> 
> We introduce an ISortable adapter which we make selectable for mandates
> and functions. This adapater will be used to ease the manipulation of
> the sortable things and is used here to select the hook.
> 

> diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
> --- a/test/unittest_hooks.py
> +++ b/test/unittest_hooks.py
> @@ -371,6 +371,18 @@ class AuthorityRecordHookTC(CubicWebTC):
>              self.assertFalse(arecord.reverse_use_authorityrecord)
>  
>  
> +class InitializeSortableIndexHookTC(CubicWebTC):
> +
> +    configcls = PostgresApptestConfiguration
> +
> +    def setup_database(self):

Ugh? def test_xxx

Also, creating new test case class has a cost (because of setupclass) so
it might be good to simply add a test method to an existing class.

> +        with self.admin_access.cnx() as cnx:
> +            arecord = testutils.authority_record(cnx, u'test')
> +            mandate = cnx.create_entity('Mandate', term=u'casting', mandate_agent=arecord)
> +            cnx.commit()
> +            self.assertEqual(mandate.eid, mandate.index)
> +
> +
>  class ExtractArkTC(unittest.TestCase):
>  
>      configcls = PostgresApptestConfiguration
> 



More information about the saem-devel mailing list