server/test/unittest_repository.py
branchstable
changeset 6236 9138f23ee263
parent 6208 07b176640a8c
child 6279 42079f752a9c
child 6340 470d8e828fda
--- a/server/test/unittest_repository.py	Tue Sep 14 15:36:29 2010 +0200
+++ b/server/test/unittest_repository.py	Tue Sep 14 15:37:32 2010 +0200
@@ -627,6 +627,18 @@
             self.assertEquals(CALLED, [('before_add_relation', eidn, 'ecrit_par', eidp),
                                        ('after_add_relation', eidn, 'ecrit_par', eidp)])
 
+    def test_unique_contraint(self):
+        req = self.request()
+        toto = req.create_entity('Personne', nom=u'toto')
+        a01 = req.create_entity('Affaire', ref=u'A01', todo_by=toto)
+        req.cnx.commit()
+        req = self.request()
+        req.create_entity('Note', type=u'todo', inline1=a01)
+        req.cnx.commit()
+        req = self.request()
+        req.create_entity('Note', type=u'todo', inline1=a01)
+        ex = self.assertRaises(ValidationError, req.cnx.commit)
+        self.assertEquals(ex.errors, {'inline1-subject': u'RQLUniqueConstraint S type T, S inline1 A1, A1 todo_by C, Y type T, Y inline1 A2, A2 todo_by C failed'})
 
 if __name__ == '__main__':
     unittest_main()