--- a/test/unittest_dbapi.py Wed Apr 11 14:16:27 2012 +0200
+++ b/test/unittest_dbapi.py Wed Apr 11 14:43:51 2012 +0200
@@ -23,10 +23,11 @@
from logilab.common import tempattr
-from cubicweb import ConnectionError, cwconfig
+from cubicweb import ConnectionError, cwconfig, NoSelectableObject
from cubicweb.dbapi import ProgrammingError
from cubicweb.devtools.testlib import CubicWebTC
+
class DBAPITC(CubicWebTC):
def test_public_repo_api(self):
@@ -82,6 +83,19 @@
req.ajax_replace_url('domid') # don't crash
req.user.cw_adapt_to('IBreadCrumbs') # don't crash
+ def test_call_service(self):
+ req = self.request()
+ ServiceClass = self.vreg['services']['test_service'][0]
+ ret_value = req.cnx.call_service('test_service', msg='coucou')
+ self.assertEqual('coucou', ServiceClass.passed_here.pop())
+ self.assertEqual('babar', ret_value)
+ with self.login('anon') as ctm:
+ with self.assertRaises(NoSelectableObject):
+ self.request().cnx.call_service('test_service', msg='toto')
+ self.rollback()
+ self.assertEqual([], ServiceClass.passed_here)
+
+
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
unittest_main()