[test] extend a bit add_type_restriction tests stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 11 Sep 2013 12:56:19 +0200
branchstable
changeset 721 91c4cbe2eeb3
parent 720 a3ddccf19ded
child 722 ef50aa5ed8ce
[test] extend a bit add_type_restriction tests
test/unittest_nodes.py
--- a/test/unittest_nodes.py	Wed Sep 11 12:51:29 2013 +0200
+++ b/test/unittest_nodes.py	Wed Sep 11 12:56:19 2013 +0200
@@ -62,27 +62,34 @@
         self.simplify = helper.simplify
 
     def test_add_is_type_restriction(self):
-        tree = self.parse('Any X WHERE X is Person')
+        tree = self.parse("Any X WHERE X is Person, X name ILIKE 'A%'")
         select = tree.children[0]
         x = select.get_selected_variables().next()
         self.assertRaises(RQLException, select.add_type_restriction, x.variable, 'Babar')
         select.add_type_restriction(x.variable, 'Person')
-        self.assertEqual(tree.as_string(), 'Any X WHERE X is Person')
+        self.assertEqual(tree.as_string(), "Any X WHERE X is Person, X name ILIKE 'A%'")
 
     def test_add_new_is_type_restriction_in(self):
+        tree = self.parse("Any X WHERE X is IN(Person, Company), X name ILIKE 'A%'")
+        select = tree.children[0]
+        x = select.get_selected_variables().next()
+        select.add_type_restriction(x.variable, 'Company')
+        # implementation is KISS (the IN remains)
+        self.assertEqual(tree.as_string(), "Any X WHERE X is IN(Company), X name ILIKE 'A%'")
+
+    def test_add_new_is_type_restriction_in_nonregr(self):
         tree = self.parse('Any X WHERE X is IN(Person, Company, Student)')
         select = tree.children[0]
         x = select.get_selected_variables().next()
         select.add_type_restriction(x.variable, 'Person')
-        # implementation is KISS (the IN remains)
         self.assertEqual(tree.as_string(), 'Any X WHERE X is IN(Person)')
 
     def test_add_is_in_type_restriction(self):
-        tree = self.parse('Any X WHERE X is IN(Person, Company)')
+        tree = self.parse("Any X WHERE X is IN(Person, Company), X name ILIKE 'A%'")
         select = tree.children[0]
         x = select.get_selected_variables().next()
         self.assertRaises(RQLException, select.add_type_restriction, x.variable, 'Babar')
-        self.assertEqual(tree.as_string(), 'Any X WHERE X is IN(Person, Company)')
+        self.assertEqual(tree.as_string(), "Any X WHERE X is IN(Person, Company), X name ILIKE 'A%'")
 
     # XXX a full schema is needed, see test in cw/server/test/unittest_security
     # def test_add_is_against_isintance_type_restriction(self):