test/unittest_schema.py
changeset 7469 f8c983afbf8e
parent 7460 2455cdbeadca
child 7604 1eb6090311ff
equal deleted inserted replaced
7466:395c966a1cb3 7469:f8c983afbf8e
    27 from rql import RQLSyntaxError
    27 from rql import RQLSyntaxError
    28 
    28 
    29 from yams import BadSchemaDefinition
    29 from yams import BadSchemaDefinition
    30 from yams.constraints import SizeConstraint, StaticVocabularyConstraint
    30 from yams.constraints import SizeConstraint, StaticVocabularyConstraint
    31 from yams.buildobjs import RelationDefinition, EntityType, RelationType
    31 from yams.buildobjs import RelationDefinition, EntityType, RelationType
    32 from yams.reader import PyFileReader
    32 from yams.reader import fill_schema
    33 
    33 
    34 from cubicweb.schema import (
    34 from cubicweb.schema import (
    35     CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader,
    35     CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader,
    36     RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint,
    36     RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint,
    37     RQLExpression, ERQLExpression, RRQLExpression,
    37     RQLExpression, ERQLExpression, RRQLExpression,
   268     def setUp(self):
   268     def setUp(self):
   269         self.loader = CubicWebSchemaLoader()
   269         self.loader = CubicWebSchemaLoader()
   270         self.loader.defined = {}
   270         self.loader.defined = {}
   271         self.loader.loaded_files = []
   271         self.loader.loaded_files = []
   272         self.loader.post_build_callbacks = []
   272         self.loader.post_build_callbacks = []
   273         self.loader._pyreader = PyFileReader(self.loader)
       
   274 
   273 
   275     def _test(self, schemafile, msg):
   274     def _test(self, schemafile, msg):
   276         self.loader.handle_file(join(DATADIR, schemafile))
   275         self.loader.handle_file(join(DATADIR, schemafile))
       
   276         sch = self.loader.schemacls('toto')
   277         with self.assertRaises(BadSchemaDefinition) as cm:
   277         with self.assertRaises(BadSchemaDefinition) as cm:
   278             self.loader._build_schema('toto', False)
   278             fill_schema(sch, self.loader.defined, False)
   279         self.assertEqual(str(cm.exception), msg)
   279         self.assertEqual(str(cm.exception), msg)
   280 
   280 
   281     def test_lowered_etype(self):
   281     def test_lowered_etype(self):
   282         self._test('lowered_etype.py',
   282         self._test('lowered_etype.py',
   283                    "'my_etype' is not a valid name for an entity type. It should "
   283                    "'my_etype' is not a valid name for an entity type. It should "