[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 26 May 2011 08:12:42 +0200
changeset 7440 539de926ec9d
parent 7439 8e1c58a212ad
child 7441 b70f4f4c8620
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
schema.py
test/unittest_schema.py
--- a/schema.py	Wed May 25 18:46:09 2011 +0200
+++ b/schema.py	Thu May 26 08:12:42 2011 +0200
@@ -528,15 +528,15 @@
         rschema = self.add_relation_type(ybo.RelationType('identity'))
         rschema.final = False
 
-    etype_name_re = r'[A-Z][A-Za-z0-9]*[a-z]+[0-9]*$'
+    etype_name_re = r'[A-Z][A-Za-z0-9]*[a-z]+[A-Za-z0-9]*$'
     def add_entity_type(self, edef):
         edef.name = edef.name.encode()
         edef.name = bw_normalize_etype(edef.name)
         if not re.match(self.etype_name_re, edef.name):
             raise BadSchemaDefinition(
-                '%r is not a valid name for an entity type. It should match '
-                'the following regular expresion: %r' % (edef.name,
-                                                         self.etype_name_re))
+                '%r is not a valid name for an entity type. It should start '
+                'with an upper cased letter and be followed by at least a '
+                'lower cased letter' % edef.name)
         eschema = super(CubicWebSchema, self).add_entity_type(edef)
         if not eschema.final:
             # automatically add the eid relation to non final entity types
--- a/test/unittest_schema.py	Wed May 25 18:46:09 2011 +0200
+++ b/test/unittest_schema.py	Thu May 26 08:12:42 2011 +0200
@@ -259,6 +259,11 @@
         self.assertEqual([x.expression for x in aschema.get_rqlexprs('update')],
                           ['U has_update_permission X'])
 
+    def test_nonregr_allowed_type_names(self):
+        schema = CubicWebSchema('Test Schema')
+        schema.add_entity_type(EntityType('NaN'))
+
+
 class BadSchemaTC(TestCase):
     def setUp(self):
         self.loader = CubicWebSchemaLoader()