[testlib] deprecate .remote_call and provide new connection api friendly .remote_calling
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 03 Jun 2014 14:43:07 +0200
changeset 9845 9c3ec404534f
parent 9844 e7d7b7793769
child 9846 67c1b77b44be
[testlib] deprecate .remote_call and provide new connection api friendly .remote_calling
devtools/testlib.py
--- a/devtools/testlib.py	Tue Jun 03 12:35:25 2014 +0200
+++ b/devtools/testlib.py	Tue Jun 03 14:43:07 2014 +0200
@@ -843,6 +843,7 @@
         publisher.error_handler = raise_error_handler
         return publisher
 
+    @deprecated('[3.19] use the .remote_calling method')
     def remote_call(self, fname, *args):
         """remote json call simulation"""
         dump = json.dumps
@@ -851,6 +852,14 @@
         ctrl = self.vreg['controllers'].select('ajax', req)
         return ctrl.publish(), req
 
+    @contextmanager
+    def remote_calling(self, fname, *args):
+        """remote json call simulation"""
+        args = [json.dumps(arg) for arg in args]
+        with self.admin_access.web_request(fname=fname, pageid='123', arg=args) as req:
+            ctrl = self.vreg['controllers'].select('ajax', req)
+            yield ctrl.publish(), req
+
     def app_handle_request(self, req, path='view'):
         return self.app.core_handle(req, path)