Server IP : 127.0.0.2 / Your IP : 18.226.181.89 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /opt/odoo/addons/web/static/test/ |
Upload File : |
odoo.testing = {}; odoo.testing.start_services = function () { var factories = odoo.__DEBUG__.factories; delete factories['mail.chat_manager']; var jobs = _.map(factories, function (factory, name) { return { name: name, factory: factory, deps: factory.deps, }; }); var services = Object.create({}); return odoo.process_jobs(jobs, services); }; odoo.testing.MockRPC = function (session) { this.clear(); }; odoo.testing.MockRPC.prototype.clear = function () { this.responses = {}; }; odoo.testing.MockRPC.prototype.interceptRPC = function (session) { session.rpc = this.rpc.bind(this); }; odoo.testing.MockRPC.prototype.add = function (spec, handler, no_override) { if (no_override && (spec in this.responses)) { return; } this.responses[spec] = handler; }; odoo.testing.MockRPC.prototype.rpc = function (url, rparams, options) { if (_.isString(url)) { url = {url: url}; } var fn, params; var needle = rparams.model + ':' + rparams.method; if (url.url.substr(0, 20) === '/web/dataset/call_kw' && needle in this.responses) { fn = this.responses[needle]; params = [ rparams.args || [], rparams.kwargs || {} ]; } else { fn = this.responses[url.url]; 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(rparams)) ).promise(); } try { return $.when(fn.apply(null, params)).then(function (result) { // Wrap for RPC layer unwrapper thingy return result; }); } catch (e) { // not sure why this looks like that return $.Deferred().reject({}, 'failed', String(e)); } }; odoo.testing.noop = function () {}; odoo.define_section = function (name, section_deps) { var section_body, options, mock; if (typeof arguments[2] === 'function') { options = {}; section_body = arguments[2]; } else { options = arguments[2]; section_body = arguments[3]; } mock = new odoo.testing.MockRPC(); function dummyfunc () {}; function beforeEach(assert) { var services = odoo.testing.start_services(); this.deps = services; this.getServiceDeps = function getServiceDeps(dep_names) { return _.map(dep_names, function (name) { return services[name]; }) } services['web.core'].qweb.add_template(odoo.testing.templates); this.mock = mock; this.mock.interceptRPC(services['web.session']); this.assert = assert; (options.beforeEach || dummyfunc).apply(this, [assert].concat(this.getServiceDeps(section_deps))); } function afterEach(assert) { (options.afterEach || dummyfunc).apply(this, [assert].concat(this.getServiceDeps(section_deps))); this.mock.clear(); } QUnit.module(name, { before: options.before, beforeEach: beforeEach, afterEach: afterEach, after: options.after }); function test () { var name = arguments[0], dep_names = arguments[1] instanceof Array ? arguments[1] : [], body = arguments[arguments.length - 1]; QUnit.test(name, function (assert) { var deps = this.getServiceDeps(section_deps.concat(dep_names)); return body.apply(this, [assert].concat(deps)); }); } section_body(test, mock); }; QUnit.done(function(result) { if (result.failed === 0) { console.log('ok'); } else { console.log('error'); } }); QUnit.log(function(result) { if (!result.result) { console.log(result.name, 'in section', result.module, 'failed:', result.message); } }); (new QWeb2.Engine()).load_xml("/web/webclient/qweb", function (err, xDoc) { odoo.testing.templates = xDoc; QUnit.start(); }); QUnit.config.autostart = false; localStorage.clear(); QUnit.config.testTimeout = 1 * 60 * 1000; QUnit.moduleDone(function(result) { if (!result.failed) { console.log(result.name, "passed", result.total, "tests."); } else { console.log(result.name, "failed:", result.failed, "tests out of", result.total, "."); } });