[PATCH 1 of 1 saem_ref] [hooks] Fix crash on attempt to set an email to a user

Denis Laxalde denis.laxalde at logilab.fr
Thu Mar 9 13:58:46 CET 2017


Sylvain Thenault a écrit :
> # HG changeset patch
> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
> # Date 1489006048 -3600
> #      Wed Mar 08 21:47:28 2017 +0100
> # Node ID fadc76dea14882852b0bb7da89d912787db09955
> # Parent  38ce60fdedd73a34567763fbdb57d466277a7735
> [hooks] Fix crash on attempt to set an email to a user
>
> because EmailAddress is part of some container through use_email.
> 'primary_email' has to be explicitly skipped to avoid adding clumsy code to
> detect that it's not a 'border' relation.
>
> Closes extranet #15224342
>

> diff --git a/dev-requirements.txt b/dev-requirements.txt
> --- a/dev-requirements.txt
> +++ b/dev-requirements.txt
> @@ -2,6 +2,6 @@ pytest
>  webtest
>  http://hg.logilab.org/master/cubes/prov/archive/tip.tar.bz2#egg=cubicweb-prov
>  http://hg.logilab.org/master/cubes/eac/archive/tip.tar.bz2#egg=cubicweb-eac
>  http://hg.logilab.org/master/cubes/seda/archive/tip.tar.bz2#egg=cubicweb-seda
>  http://hg.logilab.org/master/cubes/relationwidget/archive/tip.tar.bz2#egg=cubicweb-relationwidget
> -http://hg.logilab.org/review/cubes/compound/archive/03180a8d8475.tar.bz2#egg=cubicweb-compound
> +http://hg.logilab.org/master/cubes/compound/archive/tip.tar.bz2#egg=cubicweb-compound

Is it related?

> diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
> --- a/test/unittest_hooks.py
> +++ b/test/unittest_hooks.py
> @@ -247,10 +247,18 @@ class SAEMRefHooksTC(CubicWebTC):
>              self.assertEqual(scheme.ark, '67717/Matiere')
>              self.assertEqual(scheme.cwuri, 'http://dcf/res/ark:/67717/Matiere')
>              self.assertEqual(concept.ark, '67717/1234')
>              self.assertEqual(concept.cwuri, 'http://dcf/res/ark:/67717/1234')
>
> +    def test_user_email(self):
> +        # EmailAddress belong to the Organisation graph, hence may conflict with hooks when linked
> +        # to a user
> +        with self.admin_access.repo_cnx() as cnx:
> +            cnx.create_entity('EmailAddress', address=u'admin at cubicweb.org',
> +                              reverse_use_email=cnx.user.eid)
> +            cnx.commit()
> +

I don't understand what this test checks. Could you add an assertion?
Maybe checking that the hook was not called?


>  class AuthorityRecordHookTC(CubicWebTC):
>
>      def setup_database(self):
>          with self.admin_access.cnx() as cnx:
>


-- 
Denis Laxalde
Logilab         http://www.logilab.fr



More information about the saem-devel mailing list