test/unittest_schema.py
branch3.5
changeset 2931 17224e90a1c4
parent 2920 64322aa83a1d
parent 2926 4484387ed012
child 2943 77622caef9bd
equal deleted inserted replaced
2924:b5aadbd3fc5b 2931:17224e90a1c4
    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 CubicWebSchema, CubicWebEntitySchema, \
    22      RQLConstraint, CubicWebSchemaLoader, ERQLExpression, RRQLExpression, \
    22      RQLConstraint, CubicWebSchemaLoader, ERQLExpression, RRQLExpression, \
    23      normalize_expression
    23      normalize_expression, order_eschemas
    24 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
    24 from cubicweb.devtools import TestServerConfiguration as TestConfiguration
    25 
    25 
    26 DATADIR = join(dirname(__file__), 'data')
    26 DATADIR = join(dirname(__file__), 'data')
    27 
    27 
    28 # build a dummy schema ########################################################
    28 # build a dummy schema ########################################################
   124         self.assertRaises(Exception, RRQLExpression, '1')
   124         self.assertRaises(Exception, RRQLExpression, '1')
   125         self.assertRaises(RQLSyntaxError, RRQLExpression, 'O X Y')
   125         self.assertRaises(RQLSyntaxError, RRQLExpression, 'O X Y')
   126         expr = RRQLExpression('U has_update_permission O')
   126         expr = RRQLExpression('U has_update_permission O')
   127         self.assertEquals(str(expr), 'Any O WHERE U has_update_permission O, O eid %(o)s, U eid %(u)s')
   127         self.assertEquals(str(expr), 'Any O WHERE U has_update_permission O, O eid %(o)s, U eid %(u)s')
   128 
   128 
   129 
       
   130 loader = CubicWebSchemaLoader()
   129 loader = CubicWebSchemaLoader()
   131 config = TestConfiguration('data')
   130 config = TestConfiguration('data')
   132 config.bootstrap_cubes()
   131 config.bootstrap_cubes()
   133 
   132 
   134 class SQLSchemaReaderClassTest(TestCase):
   133 class SchemaReaderClassTest(TestCase):
       
   134 
       
   135     def test_order_eschemas(self):
       
   136         schema = loader.load(config)
       
   137         self.assertEquals(order_eschemas([schema['Note'], schema['SubNote']]),
       
   138                                          [schema['Note'], schema['SubNote']])
       
   139         self.assertEquals(order_eschemas([schema['SubNote'], schema['Note']]),
       
   140                                          [schema['Note'], schema['SubNote']])
   135 
   141 
   136     def test_knownValues_load_schema(self):
   142     def test_knownValues_load_schema(self):
   137         schema = loader.load(config)
   143         schema = loader.load(config)
   138         self.assert_(isinstance(schema, CubicWebSchema))
   144         self.assert_(isinstance(schema, CubicWebSchema))
   139         self.assertEquals(schema.name, 'data')
   145         self.assertEquals(schema.name, 'data')