test/unittest_schema.py
changeset 3998 94cc7cad3d2d
parent 3877 7ca53fc72a0a
parent 3978 2c95e3033f64
child 4181 c79135c217df
equal deleted inserted replaced
3895:92ead039d3d0 3998:94cc7cad3d2d
    16 from yams import BadSchemaDefinition
    16 from yams import BadSchemaDefinition
    17 from yams.constraints import SizeConstraint, StaticVocabularyConstraint
    17 from yams.constraints import SizeConstraint, StaticVocabularyConstraint
    18 from yams.buildobjs import RelationDefinition, EntityType, RelationType
    18 from yams.buildobjs import RelationDefinition, EntityType, RelationType
    19 from yams.reader import PyFileReader
    19 from yams.reader import PyFileReader
    20 
    20 
    21 from cubicweb.schema import CubicWebSchema, CubicWebEntitySchema, \
    21 from cubicweb.schema import (
    22      RQLConstraint, CubicWebSchemaLoader, RQLExpression, ERQLExpression, RRQLExpression, \
    22     CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader,
    23      normalize_expression, order_eschemas
    23     RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint,
       
    24     RQLExpression, ERQLExpression, RRQLExpression,
       
    25     normalize_expression, order_eschemas)
    24 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
    26 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
    25 
    27 
    26 DATADIR = join(dirname(__file__), 'data')
    28 DATADIR = join(dirname(__file__), 'data')
    27 
    29 
    28 # build a dummy schema ########################################################
    30 # build a dummy schema ########################################################
    81     else:
    83     else:
    82         schema.add_relation_def(RelationDefinition(_from, _type, _to))
    84         schema.add_relation_def(RelationDefinition(_from, _type, _to))
    83 
    85 
    84 class CubicWebSchemaTC(TestCase):
    86 class CubicWebSchemaTC(TestCase):
    85 
    87 
       
    88     def test_rql_constraints_inheritance(self):
       
    89         # isinstance(cstr, RQLVocabularyConstraint)
       
    90         # -> expected to return RQLVocabularyConstraint and RQLConstraint
       
    91         #   instances but not RQLUniqueConstraint
       
    92         #
       
    93         # isinstance(cstr, RQLConstraint)
       
    94         # -> expected to return RQLConstraint instances but not
       
    95         #    RRQLVocabularyConstraint and QLUniqueConstraint
       
    96         self.failIf(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint))
       
    97         self.failIf(issubclass(RQLUniqueConstraint, RQLConstraint))
       
    98         self.failUnless(issubclass(RQLConstraint, RQLVocabularyConstraint))
       
    99 
    86     def test_normalize(self):
   100     def test_normalize(self):
    87         """test that entities, relations and attributes name are normalized
   101         """test that entities, relations and attributes name are normalized
    88         """
   102         """
    89         self.assertEqual(esociete.type, 'Societe')
   103         self.assertEqual(esociete.type, 'Societe')
    90         self.assertEqual(schema.has_relation('TEST'), 0)
   104         self.assertEqual(schema.has_relation('TEST'), 0)