summaryrefslogtreecommitdiff
path: root/addons/web/static/test/core/rpc_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-03-07 16:13:43 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit78c97e6cc4c90036e68ad8f82b3c7d326b321067 (patch)
tree64790a456353a914b02102d7f5e6d0bb0ab35726 /addons/web/static/test/core/rpc_tests.js
parent1ec265eb92ebec9b22d471459af442572d187821 (diff)
[IMP] web: remove perform(Model)RPC
and replace them with a new, private, _rpc method. Also, extends the rpc builder to be able to send arbitrary parameters.
Diffstat (limited to 'addons/web/static/test/core/rpc_tests.js')
-rw-r--r--addons/web/static/test/core/rpc_tests.js37
1 files changed, 28 insertions, 9 deletions
diff --git a/addons/web/static/test/core/rpc_tests.js b/addons/web/static/test/core/rpc_tests.js
index beec3fce831..7c196a1155d 100644
--- a/addons/web/static/test/core/rpc_tests.js
+++ b/addons/web/static/test/core/rpc_tests.js
@@ -30,33 +30,51 @@ QUnit.module('core', {}, function () {
QUnit.module('RPC Builder');
QUnit.test('basic rpc (route)', function (assert) {
- assert.expect(1);
+ assert.expect(3);
var query = createQuery({
route: '/my/route',
- mockRPC: function (route) {
+ mockRPC: function (route, params) {
assert.strictEqual(route, '/my/route',
"should call the proper route");
- }
+ assert.notOk('args' in params,
+ "rpc on routes should not have any args by default");
+ assert.notOk('kwargs' in params,
+ "rpc on routes should not have any kwargs by default");
+ },
});
query.exec();
});
- QUnit.test('basic rpc, with no context', function (assert) {
+ QUnit.test('rpc on route with parameters', function (assert) {
assert.expect(1);
var query = createQuery({
route: '/my/route',
- mockRPC: function (route, args) {
- assert.notOk('context' in args.kwargs,
+ mockRPC: function (route, params) {
+ assert.deepEqual(params, {hey: 'there'},
+ "should transfer the proper parameters");
+ },
+ });
+ query.params({hey: 'there'}).exec();
+ });
+
+ QUnit.test('basic rpc, with no context', function (assert) {
+ assert.expect(1);
+ var query = createQuery({
+ model: 'partner',
+ method: 'test',
+ mockRPC: function (route, params) {
+ assert.notOk('context' in params.kwargs,
"does not automatically add a context");
}
});
- query.exec();
+ query.kwargs({}).exec();
});
QUnit.test('basic rpc, with context', function (assert) {
assert.expect(1);
var query = createQuery({
- route: '/my/route',
+ model: 'partner',
+ method: 'test',
mockRPC: function (route, args) {
assert.deepEqual(args.kwargs.context, {a: 1},
"properly transfer the context");
@@ -68,7 +86,8 @@ QUnit.module('core', {}, function () {
QUnit.test('basic rpc, with context, part 2', function (assert) {
assert.expect(1);
var query = createQuery({
- route: '/my/route',
+ model: 'partner',
+ method: 'test',
mockRPC: function (route, args) {
assert.deepEqual(args.kwargs.context, {a: 1},
"properly transfer the context");