fix sync_schema_props_perms test stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 18 Feb 2010 13:31:03 +0100
branchstable
changeset 4635 44a883148ab4
parent 4634 b2a3232783f8
child 4636 edafa2343dd7
fix sync_schema_props_perms test
server/test/data/schema.py
server/test/unittest_migractions.py
--- a/server/test/data/schema.py	Thu Feb 18 13:30:37 2010 +0100
+++ b/server/test/data/schema.py	Thu Feb 18 13:31:03 2010 +0100
@@ -137,7 +137,7 @@
 class para(RelationType):
     __permissions__ = {
         'read':   ('managers', 'users', 'guests'),
-        'update':    ('managers', ERQLExpression('X in_state S, S name "todo"')),
+        'update': ('managers', ERQLExpression('X in_state S, S name "todo"')),
         }
 
 class test(RelationType):
--- a/server/test/unittest_migractions.py	Thu Feb 18 13:30:37 2010 +0100
+++ b/server/test/unittest_migractions.py	Thu Feb 18 13:31:03 2010 +0100
@@ -157,7 +157,7 @@
                           sorted(str(e) for e in self.schema.entities() if not e.final))
         self.assertEquals(self.schema['filed_under2'].objects(), ('Folder2',))
         eschema = self.schema.eschema('Folder2')
-        for cstr in eschema.constraints('name'):
+        for cstr in eschema.rdef('name').constraints:
             self.failUnless(hasattr(cstr, 'eid'))
 
     def test_add_drop_entity_type(self):
@@ -281,7 +281,7 @@
     def test_sync_schema_props_perms(self):
         cursor = self.mh.session
         cursor.set_pool()
-        nbrqlexpr_start = len(cursor.execute('RQLExpression X'))
+        nbrqlexpr_start = cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0]
         migrschema['titre'].rdefs[('Personne', 'String')].order = 7
         migrschema['adel'].rdefs[('Personne', 'String')].order = 6
         migrschema['ass'].rdefs[('Personne', 'String')].order = 5
@@ -350,14 +350,19 @@
         self.assertEquals(len(self._rrqlexpr_rset('delete', 'concerne')), len(delete_concerne_rqlexpr))
         self.assertEquals(len(self._rrqlexpr_rset('add', 'concerne')), len(add_concerne_rqlexpr))
         # * migrschema involve:
-        #   * 8 deletion (2 in Affaire read + Societe + travaille + para rqlexprs)
+        #   * 7 rqlexprs deletion (2 in (Affaire read + Societe + travaille) + 1
+        #     in para attribute)
         #   * 1 update (Affaire update)
         #   * 2 new (Note add, ecrit_par add)
+        #   * 2 implicit new for attributes update_permission (Note.para, Personne.test)
         # remaining orphan rql expr which should be deleted at commit (composite relation)
-        self.assertEquals(len(cursor.execute('RQLExpression X WHERE NOT ET1 read_permission X, NOT ET2 add_permission X, '
-                                             'NOT ET3 delete_permission X, NOT ET4 update_permission X')), 8+1)
+        self.assertEquals(cursor.execute('Any COUNT(X) WHERE X is RQLExpression, '
+                                         'NOT ET1 read_permission X, NOT ET2 add_permission X, '
+                                         'NOT ET3 delete_permission X, NOT ET4 update_permission X')[0][0],
+                          7+1)
         # finally
-        self.assertEquals(len(cursor.execute('RQLExpression X')), nbrqlexpr_start + 1 + 2)
+        self.assertEquals(cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0],
+                          nbrqlexpr_start + 1 + 2 + 2)
 
         self.mh.rollback()