server/test/unittest_migractions.py
branchstable
changeset 6208 07b176640a8c
parent 6163 407f54345687
child 6292 054fa36060d5
child 6340 470d8e828fda
--- a/server/test/unittest_migractions.py	Fri Sep 10 15:09:31 2010 +0200
+++ b/server/test/unittest_migractions.py	Fri Sep 10 16:48:58 2010 +0200
@@ -309,6 +309,7 @@
         migrschema['titre'].rdefs[('Personne', 'String')].description = 'title for this person'
         delete_concerne_rqlexpr = self._rrqlexpr_rset('delete', 'concerne')
         add_concerne_rqlexpr = self._rrqlexpr_rset('add', 'concerne')
+        
         self.mh.cmd_sync_schema_props_perms(commit=False)
 
         self.assertEquals(cursor.execute('Any D WHERE X name "Personne", X description D')[0][0],
@@ -380,8 +381,15 @@
         # finally
         self.assertEquals(cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0],
                           nbrqlexpr_start + 1 + 2 + 2)
-
-        self.mh.rollback()
+        self.mh.commit()
+        # unique_together test
+        self.assertEqual(len(self.schema.eschema('Personne')._unique_together), 1)
+        self.assertUnorderedIterableEquals(self.schema.eschema('Personne')._unique_together[0],
+                                           ('nom', 'prenom', 'datenaiss'))
+        rset = cursor.execute('Any C WHERE C is CWUniqueTogetherConstraint')
+        self.assertEquals(len(rset), 1)
+        relations = [r.rtype.name for r in rset.get_entity(0,0).relations]
+        self.assertUnorderedIterableEquals(relations, ('nom', 'prenom', 'datenaiss'))
 
     def _erqlexpr_rset(self, action, ertype):
         rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action