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

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Apr 11 15:22:16 CEST 2017


# 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 0bc3261c085382cb1d5aff5e79cdb30013d03a27
# Parent  d59fc13d4ab13e2ace3177ca0782bd3bae2204b2
[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,38 @@ 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').cnx() as cnx:
+            scheme = cnx.create_entity('ConceptScheme', title=u'Some vocabulary')
+            cnx.commit()
+
+            etype = cnx.find('CWEType', name=u'CWEType').one()
+            with self.assertUnauthorized(cnx):
+                scheme.cw_set(scheme_entity_type=etype)
+
+            rtype = cnx.find('CWRType', name=u'name').one()
+            with self.assertUnauthorized(cnx):
+                scheme.cw_set(scheme_relation_type=rtype)
+
+    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').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')}


More information about the saem-devel mailing list