[PATCH 2 of 5 seda] [test/security] Add test about some relation from ConceptScheme

Sylvain Thénault sylvain.thenault at logilab.fr
Tue Apr 11 15:32:24 CEST 2017


sent a V2 addressing comments in this email


Le 11/04/2017 à 15:13, Philippe Pepiot a écrit :
> On 04/10/2017 05:48 PM, Sylvain Thenault wrote:
>> # HG changeset patch
>> # User Sylvain Thénault <sylvain.thenault at logilab.fr>
>> # Date 1491831763 -7200
>> #      Mon Apr 10 15:42:43 2017 +0200
>> # Node ID 07350ed1e41071babe8e698f5435378704e96550
>> # Parent  8f62b2d83afd4a325178ae4aa6908d9b8567c408
>> [test/security] Add test about some relation from ConceptScheme
>>
>> * scheme_relation_type / scheme_entity_type (reserved to managers)
>> * code_keyword_type (users friendly)
>>
>> diff --git a/test/test_schema.py b/test/test_schema.py
>> --- a/test/test_schema.py
>> +++ b/test/test_schema.py
>> @@ -367,10 +367,35 @@ class SecurityTC(CubicWebTC):
>>              cnx.commit()
>>              cloned.cw_clear_all_caches()
>>
>>              self.assertTrue(cloned.first_level_choice.content_sequence)
>>
>> +    def test_scheme_type(self):
>> +        with self.new_access('alice').repo_cnx() as cnx:
>
>
> For consistency you could use cnx() instead of repo_cnx()
>
>
>> +            scheme = cnx.create_entity('ConceptScheme', title=u'Some
>> vocabulary')
>> +            cnx.commit()
>> +
>> +            with self.assertUnauthorized(cnx):
>> +                scheme.cw_set(scheme_entity_type=cnx.find('CWEType',
>> name=u'CWEType').one())
>> +            with self.assertUnauthorized(cnx):
>> +               
>> scheme.cw_set(scheme_relation_type=cnx.find('CWRType',
>> name=u'name').one())
>> +
>
>
> It's not clear to me that cnx.find() can or cannot raise Unauthorized.
> Either add an assertion on the exception message or move the
> cnx.find() outside of the context manager.
>
>
>> +    def test_scheme_code_keyword_type(self):
>> +        with self.admin_access.cnx() as cnx:
>> +            admin_scheme = testutils.scheme_for_type(cnx,
>> u'seda_keyword_type_to', None,
>> +                                                     u'type1')
>> +            cnx.commit()
>> +            type_concept = admin_scheme.reverse_in_scheme[0]
>> +
>> +        with self.new_access('alice').repo_cnx() as cnx:
>> +            # ensure code_keyword_type is editable by standard user
>> +            scheme = cnx.create_entity('ConceptScheme', title=u'Some
>> vocabulary',
>> +                                       code_keyword_type=type_concept)
>> +            cnx.commit()
>> +            scheme.cw_set(code_keyword_type=None)
>> +            cnx.commit()
>> +
>>
>>  class SchemaIteratorTC(CubicWebTC):
>>
>>      def test_iter_all_rdefs(self):
>>          values = {str(rdef) for rdef, role in
>> iter_all_rdefs(self.schema, 'SEDABinaryDataObject')}
>>
>

-- 
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