[FIX] various issues with JS tests
bzr revid: xmo@openerp.com-20140203120553-foe2jutor33j1b8q
This commit is contained in:
commit
5de043e044
|
@ -15,6 +15,37 @@ openerp.testing = {};
|
|||
list_editable: ['list', 'form', 'data'],
|
||||
};
|
||||
|
||||
var initialized = [];
|
||||
/**
|
||||
* openerp.init is a broken-ass piece of shit, makes it impossible to
|
||||
* progressively add modules, using it, retarded openerp_inited flag
|
||||
* means the first tests being run get their dependencies loaded
|
||||
* (basically just base and web), and for *every other module* the tests
|
||||
* run without the dependencies being correctly loaded
|
||||
*/
|
||||
function init(modules) {
|
||||
if (!initialized.length) {
|
||||
openerp.init(modules);
|
||||
initialized = openerp._modules.slice();
|
||||
return;
|
||||
}
|
||||
var to_initialize = _.difference(modules, initialized);
|
||||
for (var i = 0; i < to_initialize.length; i++) {
|
||||
var modname = to_initialize[i];
|
||||
var fct = openerp[modname];
|
||||
if (typeof fct === 'function') {
|
||||
var module = openerp[modname] = {};
|
||||
for(var k in fct) {
|
||||
if (!fct.hasOwnProperty(k)) { continue; }
|
||||
module[k] = fct[k];
|
||||
}
|
||||
fct(openerp, module)
|
||||
}
|
||||
initialized.push(modname);
|
||||
openerp._modules.push(modname);
|
||||
}
|
||||
}
|
||||
|
||||
testing.dependencies = window['oe_all_dependencies'] || [];
|
||||
testing.current_module = null;
|
||||
testing.templates = { };
|
||||
|
@ -165,8 +196,6 @@ openerp.testing = {};
|
|||
});
|
||||
};
|
||||
|
||||
var openerp_inited = false;
|
||||
|
||||
var db = window['oe_db_info'];
|
||||
testing.section = function (name, options, body) {
|
||||
if (_.isFunction(options)) {
|
||||
|
@ -243,10 +272,7 @@ openerp.testing = {};
|
|||
|
||||
QUnit.test(name, function () {
|
||||
var instance = openerp;
|
||||
if (!openerp_inited) {
|
||||
openerp.init(module_deps);
|
||||
openerp_inited = true;
|
||||
}
|
||||
init(module_deps);
|
||||
instance.session = new instance.web.Session();
|
||||
instance.session.uid = 42;
|
||||
if (_.isNumber(opts.asserts)) {
|
||||
|
|
|
@ -156,7 +156,6 @@ ropenerp.testing.section('jsonrpc-auth', {
|
|||
rpc: "rpc",
|
||||
},
|
||||
function (test) {
|
||||
return;
|
||||
test('basic-auth', {asserts: 3}, function () {
|
||||
var db = ropenerp.session.db;
|
||||
var session = new openerp.Session(null, null, {override_session: true});
|
||||
|
@ -182,7 +181,6 @@ function (test) {
|
|||
session2 = new openerp.Session(null, null, {session_id: session.session_id});
|
||||
equal(session2.uid, undefined, "uid should be undefined");
|
||||
equal(session2.override_session, true, "overwrite_session should be true");
|
||||
console.log("session_id", session.session_id);
|
||||
return session2.session_reload();
|
||||
}).then(function() {
|
||||
equal(session2.uid, session.uid);
|
||||
|
|
|
@ -110,6 +110,8 @@ class QUnitSuite(unittest.TestSuite):
|
|||
self._test.failed = True
|
||||
result.addFailure(
|
||||
self._test, self.failure_to_str(*args[2:]))
|
||||
elif event_name == 'console':
|
||||
print args[1]
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -10,12 +10,6 @@ class WebSuite(QUnitSuite):
|
|||
'/web/tests',
|
||||
'mod=*&source={db}&supadmin={supadmin}&password={password}'.format(
|
||||
db=tools.config['db_name'],
|
||||
# al: i dont understand why both are needed, db_password is the
|
||||
# password for postgres and should not appear here of that i'm
|
||||
# sure
|
||||
#
|
||||
# But runbot provides it with this wrong key so i let it here
|
||||
# until it's fixed
|
||||
supadmin=tools.config['db_password'] or 'admin',
|
||||
password=tools.config['admin_passwd'] or 'admin'),
|
||||
''
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
// niv: I desactivate these until the testing framework has been adapted to better use
|
||||
// the new way to declare JavaScript modules
|
||||
/*openerp.testing.section('basic section', function (test) {
|
||||
openerp.testing.section('basic section', function (test) {
|
||||
test('my first test', function () {
|
||||
ok(true, "this test has run");
|
||||
});
|
||||
|
@ -88,18 +86,18 @@
|
|||
});
|
||||
});
|
||||
|
||||
// test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) {
|
||||
// var Model = new instance.web.Model('web_tests_demo.model');
|
||||
// return Model.call('create', [{name: "Bob"}])
|
||||
// .then(function (id) {
|
||||
// return Model.call('read', [[id]]);
|
||||
// }).then(function (records) {
|
||||
// strictEqual(records.length, 1);
|
||||
// var record = records[0];
|
||||
// strictEqual(record.name, "Bob");
|
||||
// strictEqual(record.thing, false);
|
||||
// // default value
|
||||
// strictEqual(record.other, 'bob');
|
||||
// });
|
||||
// });
|
||||
});*/
|
||||
test('actual RPC', {rpc: 'rpc', asserts: 4}, function (instance) {
|
||||
var Model = new instance.web.Model('web_tests_demo.model');
|
||||
return Model.call('create', [{name: "Bob"}])
|
||||
.then(function (id) {
|
||||
return Model.call('read', [[id]]);
|
||||
}).then(function (records) {
|
||||
strictEqual(records.length, 1);
|
||||
var record = records[0];
|
||||
strictEqual(record.name, "Bob");
|
||||
strictEqual(record.thing, false);
|
||||
// default value
|
||||
strictEqual(record.other, 'bob');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue