[test/security] Add test about some relation from ConceptScheme
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 10 Apr 2017 15:42:43 +0200
changeset 2612 9220e0ebf255
parent 2611 6463152ee353
child 2613 71f04ef316cb
[test/security] Add test about some relation from ConceptScheme * scheme_relation_type / scheme_entity_type (reserved to managers) * code_keyword_type (users friendly)
test/test_schema.py
--- a/test/test_schema.py	Mon Apr 10 15:38:14 2017 +0200
+++ b/test/test_schema.py	Mon Apr 10 15:42:43 2017 +0200
@@ -369,6 +369,34 @@
 
             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):