--- a/cubicweb/hooks/test/unittest_hooks.py Fri Mar 24 14:18:17 2017 +0100
+++ b/cubicweb/hooks/test/unittest_hooks.py Mon Mar 27 17:57:27 2017 +0200
@@ -30,6 +30,7 @@
from cubicweb import ValidationError
from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.server.hook import Operation
class CoreHooksTC(CubicWebTC):
@@ -217,6 +218,21 @@
'login': u'login is part of violated unicity constraint'})
+class OperationTC(CubicWebTC):
+
+ def test_bad_postcommit_event(self):
+
+ class BadOp(Operation):
+ def postcommit_event(self):
+ raise RuntimeError('this is bad')
+
+ with self.admin_access.cnx() as cnx:
+ BadOp(cnx)
+ with self.assertRaises(RuntimeError) as cm:
+ cnx.commit()
+ self.assertEqual(str(cm.exception), 'this is bad')
+
+
if __name__ == '__main__':
import unittest
unittest.main()