# HG changeset patch # User Aurelien Campeas # Date 1401799387 -7200 # Node ID 9c3ec404534f9acb1ab45ee468d8e21f0fdf6b16 # Parent e7d7b7793769fcd694d08899997073f5d67aa8f4 [testlib] deprecate .remote_call and provide new connection api friendly .remote_calling diff -r e7d7b7793769 -r 9c3ec404534f 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)