From dae87b45352d18f91a8e27b0b868c4fd8ef3a1b0 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 31 Jul 2013 18:34:15 +0200 Subject: Try to reimplement jsonrpc with niv's methods, still a lot of tests fail bzr revid: nicolas.vanhoren@openerp.com-20130731163415-v6ec0nqsr0qj91a6 --- addons/web/static/src/js/testing.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/testing.js') diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index af434c4c0f4..54ffe8ce408 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -53,25 +53,28 @@ openerp.testing = {}; testing.mockifyRPC = function (instance, responses) { var session = instance.session; session.responses = responses || {}; - session.rpc_function = function (url, payload) { + session.rpc = function(url, rparams, options) { + if (_.isString(url)) { + url = {url: url}; + } var fn, params; - var needle = payload.params.model + ':' + payload.params.method; + var needle = rparams.model + ':' + rparams.method; if (url.url === '/web/dataset/call_kw' && needle in this.responses) { fn = this.responses[needle]; params = [ - payload.params.args || [], - payload.params.kwargs || {} + rparams.args || [], + rparams.kwargs || {} ]; } else { fn = this.responses[url.url]; - params = [payload]; + params = [{params: rparams}]; } if (!fn) { return $.Deferred().reject({}, 'failed', _.str.sprintf("Url %s not found in mock responses, with arguments %s", - url.url, JSON.stringify(payload.params)) + url.url, JSON.stringify(rparams)) ).promise(); } try { -- cgit v1.2.3 From f6318cc753b9a521b2245159cce5dfe3c041a75e Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 1 Aug 2013 18:08:47 +0200 Subject: Yiiiiha! This day was shitty but that damn tests finally work. bzr revid: nicolas.vanhoren@openerp.com-20130801160847-tcx6va9x1kp0q7eo --- addons/web/static/src/js/testing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/testing.js') diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index 4e310a9f4a9..052fe3312bb 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -80,7 +80,7 @@ openerp.testing = {}; try { return $.when(fn.apply(null, params)).then(function (result) { // Wrap for RPC layer unwrapper thingy - return {result: result}; + return result; }); } catch (e) { // not sure why this looks like that -- cgit v1.2.3