diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-08-06 14:07:24 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-08-06 14:07:24 +0200 |
| commit | 392e9d260bb692e4fa404848e70c6dc7ea61c36a (patch) | |
| tree | d3d65a03e90c29deb73cf72a7a5b758d303dd647 /addons/web/static/src/js/testing.js | |
| parent | 122f0aa9b39f0ed26dc26d09e4afffd949730cd1 (diff) | |
| parent | cb55e11c700efa298a74da781a108185682325da (diff) | |
[IMP] Mostly improvements of openerpframework.js . Moved a lot of necessary features to it (jsonrpc, models, translations,...). Added tests. Also some other style improvements.
bzr revid: nicolas.vanhoren@openerp.com-20130806120724-55nsh8ay9qiac72r
Diffstat (limited to 'addons/web/static/src/js/testing.js')
| -rw-r--r-- | addons/web/static/src/js/testing.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index 880da9f1bc1..052fe3312bb 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -53,31 +53,34 @@ 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 { 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 |
