[PATCH Skillmat cube] Test: fix test_owned_by_auto_set_4

Philippe Pepiot philippe.pepiot at logilab.fr
Fri Jun 7 15:31:29 CEST 2019


On 31/05/2019, Nsukami Patrick wrote:
> # HG changeset patch
> # User Nsukami Patrick <ndkpatt at gmail dot com>
> # Date 1559136608 0
> #      Wed May 29 13:30:08 2019 +0000
> # Node ID 05826f397ed7ecc575aa0ec1f615788c57d26ffd
> # Parent  d37a3f487f499ae6312c5136cbb314938c0196a2
> Test: fix test_owned_by_auto_set_4


I actually send the same patch one month ago
https://lists.cubicweb.org/pipermail/cubicweb-devel/2019-April/002768.html

I take this patch for a LGTM then :D

> 
> diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
> --- a/test/unittest_hooks.py
> +++ b/test/unittest_hooks.py
> @@ -51,17 +51,17 @@
>  
>      def test_owned_by_auto_set_4(self):
>          """test owned_by insertion when targeted user is the creator"""
> -        self.login('joe')
> -        skilleid = self.skill.eid
> -        meid = self.execute('INSERT Masters M: M rate 3, M skill S WHERE '
> -                            'S eid %(s)s', {'s': skilleid})[0][0]
> -        # should only owned by admin at this point
> -        owners = self.execute('Any L WHERE U login L, M owned_by U, M eid %s' % meid)
> -        self.assertSetEqual(set(row[0] for row in owners), set(('joe',)))
> -        self.execute('SET M foruser U WHERE M eid %s, U eid %s' % (meid, self.u.eid))
> -        # should now be owned by admin and targeted user
> -        owners = self.execute('Any L WHERE U login L, M owned_by U, M eid %s' % meid)
> -        self.assertSetEqual(set(row[0] for row in owners), set(('joe',)))
> +        with self.new_access(u'joe').cnx() as cnx:
> +            skilleid = self.skill.eid
> +            meid = cnx.execute('INSERT Masters M: M rate 3, M skill S WHERE '
> +                               'S eid %(s)s', {'s': skilleid})[0][0]
> +            # should only owned by admin at this point
> +            owners = cnx.execute('Any L WHERE U login L, M owned_by U, M eid %s' % meid)
> +            self.assertSetEqual(set(row[0] for row in owners), set(('joe',)))
> +            cnx.execute('SET M foruser U WHERE M eid %s, U eid %s' % (meid, self.u.eid))
> +            # should now be owned by admin and targeted user
> +            owners = cnx.execute('Any L WHERE U login L, M owned_by U, M eid %s' % meid)
> +            self.assertSetEqual(set(row[0] for row in owners), set(('joe',)))
>  
>  
>  if __name__ == '__main__':



More information about the cubicweb-devel mailing list