test/unittest_schema.py
branchstable
changeset 3978 2c95e3033f64
parent 3899 78a2c8e7eef5
child 3998 94cc7cad3d2d
child 4132 440d383367eb
--- a/test/unittest_schema.py	Wed Dec 02 18:36:16 2009 +0100
+++ b/test/unittest_schema.py	Thu Dec 03 09:55:18 2009 +0100
@@ -18,9 +18,11 @@
 from yams.buildobjs import RelationDefinition, EntityType, RelationType
 from yams.reader import PyFileReader
 
-from cubicweb.schema import CubicWebSchema, CubicWebEntitySchema, \
-     RQLConstraint, CubicWebSchemaLoader, ERQLExpression, RRQLExpression, \
-     normalize_expression, order_eschemas
+from cubicweb.schema import (
+    CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader,
+    RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint,
+    ERQLExpression, RRQLExpression,
+    normalize_expression, order_eschemas)
 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
 
 DATADIR = join(dirname(__file__), 'data')
@@ -82,6 +84,18 @@
 
 class CubicWebSchemaTC(TestCase):
 
+    def test_rql_constraints_inheritance(self):
+        # isinstance(cstr, RQLVocabularyConstraint)
+        # -> expected to return RQLVocabularyConstraint and RQLConstraint
+        #   instances but not RQLUniqueConstraint
+        #
+        # isinstance(cstr, RQLConstraint)
+        # -> expected to return RQLConstraint instances but not
+        #    RRQLVocabularyConstraint and QLUniqueConstraint
+        self.failIf(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint))
+        self.failIf(issubclass(RQLUniqueConstraint, RQLConstraint))
+        self.failUnless(issubclass(RQLConstraint, RQLVocabularyConstraint))
+
     def test_normalize(self):
         """test that entities, relations and attributes name are normalized
         """