server/test/unittest_migractions.py
branchstable
changeset 4635 44a883148ab4
parent 4191 01638461d4b0
child 4681 5f72584ab1d7
--- 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()