From b79f35471ecd27f1372849a9fd63cac7f740d2fd Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 21 Feb 2014 10:55:00 +0100 Subject: [PATCH 2/7] [FIX] testing: rpc tests works directly on the source database instead of copying it bzr revid: chs@openerp.com-20140221095500-5cer5exzdei76y1d --- addons/web/static/src/js/testing.js | 33 +++++------------------------ 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index c4f5aeebd60..41dd2f03ad9 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -305,39 +305,16 @@ openerp.testing = {}; case 'rpc': async = true; (function () { - // Bunch of random base36 characters - var dbname = 'test_' + Math.random().toString(36).slice(2); - // Add db setup/teardown at the start of the stack + // Add a session setup at the start of the stack to ensure user is logged in case_stack = case_stack.unshift(function (instance) { // FIXME hack: don't want the session to go through shitty loading process of everything instance.session.session_init = testing.noop; instance.session.load_modules = testing.noop; instance.session.session_bind(); - return instance.session.rpc('/web/database/duplicate', { - fields: [ - {name: 'super_admin_pwd', value: db.supadmin}, - {name: 'db_original_name', value: db.source}, - {name: 'db_name', value: dbname} - ] - }).then(function (result) { - if (result.error) { - return $.Deferred().reject(result.error).promise(); - } - return instance.session.session_authenticate( - dbname, 'admin', db.password, true); - }); - }, function (instance) { - return instance.session.rpc('/web/database/drop', { - fields: [ - {name: 'drop_pwd', value: db.supadmin}, - {name: 'drop_db', value: dbname} - ] - }).then(function (result) { - if (result.error) { - return $.Deferred().reject(result.error).promise(); - } - return result; - }); + if (instance.session.session_is_valid()) { + return $.when(); + } + return instance.session.session_authenticate(db.source, 'admin', db.password, true); }); })(); } From 636b3ff2dd331b0c488c24f68ab266b7f4350c41 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 21 Feb 2014 10:55:43 +0100 Subject: [PATCH 3/7] [FIX] testing: only load js tests of loaded modules bzr revid: chs@openerp.com-20140221095543-07lv6as8ym17mj7z --- addons/web/controllers/testing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 598270cfe54..f58482f7759 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -8,7 +8,7 @@ import operator import os from mako.template import Template -from openerp.modules import module +from openerp.modules import module, registry from openerp import http from openerp.http import request @@ -90,7 +90,11 @@ class TestRunnerController(http.Controller): @http.route('/web/tests', type='http', auth="none") def index(self, mod=None, **kwargs): - ms = module.get_modules() + source = kwargs.get('source') + if source: + ms = list(registry.RegistryManager.get(source)._init_modules) + else: + ms = module.get_modules() manifests = dict( (name, desc) for name, desc in zip(ms, map(self.load_manifest, ms)) From d27526d088653a5f9e892a1fe48829724274d8ee Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Feb 2014 13:45:57 +0100 Subject: [PATCH 4/7] [IMP] JS unit tests split automated suite so web only runs its own JS tests, and web_tests_demo runs its own. Also reversed changes to index. todo: use hack cursor thing? bzr revid: xmo@openerp.com-20140221124557-s875nj0xrf2t85i9 --- addons/web/controllers/testing.py | 8 ++------ addons/web/tests/test_js.py | 15 +++++++++------ addons/web_tests_demo/tests/__init__.py | 2 ++ addons/web_tests_demo/tests/test_js.py | 6 ++++++ 4 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 addons/web_tests_demo/tests/__init__.py create mode 100644 addons/web_tests_demo/tests/test_js.py diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index f58482f7759..598270cfe54 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -8,7 +8,7 @@ import operator import os from mako.template import Template -from openerp.modules import module, registry +from openerp.modules import module from openerp import http from openerp.http import request @@ -90,11 +90,7 @@ class TestRunnerController(http.Controller): @http.route('/web/tests', type='http', auth="none") def index(self, mod=None, **kwargs): - source = kwargs.get('source') - if source: - ms = list(registry.RegistryManager.get(source)._init_modules) - else: - ms = module.get_modules() + ms = module.get_modules() manifests = dict( (name, desc) for name, desc in zip(ms, map(self.load_manifest, ms)) diff --git a/addons/web/tests/test_js.py b/addons/web/tests/test_js.py index 0d4a9f35a85..0bab1de96a5 100644 --- a/addons/web/tests/test_js.py +++ b/addons/web/tests/test_js.py @@ -1,21 +1,24 @@ +import urllib import urlparse from openerp import sql_db, tools from qunitsuite.suite import QUnitSuite class WebSuite(QUnitSuite): - def __init__(self): + def __init__(self, module): url = urlparse.urlunsplit([ 'http', 'localhost:{port}'.format(port=tools.config['xmlrpc_port']), '/web/tests', - 'mod=*&source={db}&supadmin={supadmin}&password={password}'.format( - db=tools.config['db_name'], - supadmin=tools.config['admin_passwd'], - password='admin'), + urllib.urlencode({ + 'mod': module, + 'source': tools.config['db_name'], + 'supadmin': tools.config['admin_passwd'], + 'password': 'admin', + }), '' ]) super(WebSuite, self).__init__(url, 50000) def load_tests(loader, standard_tests, _): - standard_tests.addTest(WebSuite()) + standard_tests.addTest(WebSuite('web')) return standard_tests diff --git a/addons/web_tests_demo/tests/__init__.py b/addons/web_tests_demo/tests/__init__.py new file mode 100644 index 00000000000..1db9e399fd2 --- /dev/null +++ b/addons/web_tests_demo/tests/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import test_js diff --git a/addons/web_tests_demo/tests/test_js.py b/addons/web_tests_demo/tests/test_js.py new file mode 100644 index 00000000000..fb97176bad2 --- /dev/null +++ b/addons/web_tests_demo/tests/test_js.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from openerp.addons.web.tests.test_js import WebSuite + +def load_tests(loader, standard_tests, _): + standard_tests.addTest(WebSuite('web_tests_demo')) + return standard_tests From 42763039f0ceb3fcaf875d6afbc29d9ea9827350 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Feb 2014 15:35:12 +0100 Subject: [PATCH 5/7] [IMP] filter out phantomjs warning on OSX bzr revid: xmo@openerp.com-20140221143512-0qmmxq0gibmdgk6d --- addons/web/tests/qunitsuite/suite.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web/tests/qunitsuite/suite.py b/addons/web/tests/qunitsuite/suite.py index 1b6bc7ae0ac..54d2e18e36e 100644 --- a/addons/web/tests/qunitsuite/suite.py +++ b/addons/web/tests/qunitsuite/suite.py @@ -59,7 +59,7 @@ class QUnitSuite(unittest.TestSuite): 'timeout': self.timeout, 'inject': os.path.join(ROOT, 'qunit-phantomjs-bridge.js') }) - ], stdout=subprocess.PIPE) + ], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) try: while True: @@ -75,7 +75,12 @@ class QUnitSuite(unittest.TestSuite): phantom.terminate() def process(self, line, result): - args = json.loads(line) + try: + args = json.loads(line) + except ValueError: # phantomjs stderr + if 'CoreText' not in line: + print line + return False event_name = args[0] if event_name == 'qunit.done': From bb7eb5269917cfde51abb50a4dca175ddd371fb9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 21 Feb 2014 15:35:18 +0100 Subject: [PATCH 6/7] [REM] RPC from js/qunit tests They're a pain in the ass, they never worked right and they're basically useless. Screw it. bzr revid: xmo@openerp.com-20140221143518-hv3rjkw2b00ughvh --- addons/web/controllers/testing.py | 9 +--- addons/web/static/src/js/testing.js | 50 ------------------- addons/web/static/test/jsonrpc.js | 58 ----------------------- addons/web_tests_demo/static/test/demo.js | 15 ------ 4 files changed, 1 insertion(+), 131 deletions(-) diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 598270cfe54..c99efed4294 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -52,7 +52,6 @@ TESTING = Template(u"""