# HG changeset patch # User Sylvain Thénault # Date 1320860581 -3600 # Node ID f57ffbfe90fe57623c3c86c9f871e3233ed50ade # Parent a7f76e322659d55c4274e8df2fc8e33c285e1abe [test] add some tests for rql's add_type_restriction diff -r a7f76e322659 -r f57ffbfe90fe server/test/unittest_security.py --- a/server/test/unittest_security.py Wed Nov 09 18:41:12 2011 +0100 +++ b/server/test/unittest_security.py Wed Nov 09 18:43:01 2011 +0100 @@ -570,6 +570,26 @@ self.assertEqual(names, sorted(names, key=lambda x: x.lower())) cnx.close() + def test_restrict_is_instance_ok(self): + from rql import RQLException + rset = self.execute('Any X WHERE X is_instance_of BaseTransition') + rqlst = rset.syntax_tree() + select = rqlst.children[0] + x = select.get_selected_variables().next() + self.assertRaises(RQLException, select.add_type_restriction, + x.variable, 'CWUser') + select.add_type_restriction(x.variable, 'BaseTransition') + select.add_type_restriction(x.variable, 'WorkflowTransition') + self.assertEqual(rqlst.as_string(), 'Any X WHERE X is_instance_of WorkflowTransition') + + def test_restrict_is_instance_no_supported(self): + rset = self.execute('Any X WHERE X is_instance_of IN(CWUser, CWGroup)') + rqlst = rset.syntax_tree() + select = rqlst.children[0] + x = select.get_selected_variables().next() + self.assertRaises(NotImplementedError, select.add_type_restriction, + x.variable, 'WorkflowTransition') + def test_in_state_without_update_perm(self): """check a user change in_state without having update permission on the subject