From 403e991b2ea62fb0abd8c3dd8c7796b1099fcdd7 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 24 Apr 2014 23:28:26 +0200 Subject: [FIX] Fix web test with temporary hack bzr revid: fme@openerp.com-20140424212826-k8amd45orv33u8bn --- addons/web/controllers/testing.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index a51b619d49f..932da58fa07 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -62,6 +62,7 @@ TESTING = Template(u"""
+ % for module, jss, tests, templates in files: % for js in jss: % if not js.endswith('/apps.js'): -- cgit v1.2.3 From bc4620d2c6108745550e58cdac7eab1b07805079 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Fri, 25 Apr 2014 11:03:58 +0200 Subject: [FIX] Still trying to fix tests bzr revid: fme@openerp.com-20140425090358-1ydohuemx1tk715u --- addons/web/controllers/testing.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 932da58fa07..63eac97f9e0 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -61,8 +61,8 @@ TESTING = Template(u"""
- - + +${bundle('web.assets_backend') | n} % for module, jss, tests, templates in files: % for js in jss: % if not js.endswith('/apps.js'): @@ -134,10 +134,16 @@ class TestRunnerController(http.Controller): for mod, tests in itertools.izip(sorted_mods, tests) ] - return TESTING.render(files=files, dependencies=json.dumps( + def bundle(xmlid): + return request.render(xmlid, lazy=False) + + return TESTING.render(bundle=bundle, files=files, dependencies=json.dumps( [name for name in sorted_mods if module.get_module_resource(name, 'static') - if manifests[name]['js']])) + # TODO fme: find a way to detect modules with js bundles + # if manifests[name]['js'] + ])) + def load_manifest(self, name): manifest = module.load_information_from_description_file(name) -- cgit v1.2.3 From 8f90b2fcbcb6833debdd78beb10933087ed3353b Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Fri, 25 Apr 2014 17:45:29 +0200 Subject: [FIX] ensure_db() for /web/tests should fix tests bzr revid: fme@openerp.com-20140425154529-mmo20479tkqzfnm0 --- addons/web/controllers/testing.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 63eac97f9e0..c195c7e54b6 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -10,6 +10,7 @@ import os from mako.template import Template from openerp.modules import module from openerp import http +from openerp.addons.web.controllers.main import ensure_db from openerp.http import request from .main import module_topological_sort @@ -90,6 +91,7 @@ class TestRunnerController(http.Controller): @http.route('/web/tests', type='http', auth="none") def index(self, mod=None, **kwargs): + ensure_db() ms = module.get_modules() manifests = dict( (name, desc) -- cgit v1.2.3 From 18615e2493e829981206a59f89ef08e4869ec9cf Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 28 Apr 2014 10:16:02 +0200 Subject: [TRY] to get runbot green bzr revid: fme@openerp.com-20140428081602-c1u8jbvjnoni7sds --- addons/web/controllers/testing.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index c195c7e54b6..60702a6abfe 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -91,6 +91,7 @@ class TestRunnerController(http.Controller): @http.route('/web/tests', type='http', auth="none") def index(self, mod=None, **kwargs): + request.params['db'] = request.params.get('source') ensure_db() ms = module.get_modules() manifests = dict( -- cgit v1.2.3 From d60af567ad24bc4b83d916ec1834bbcd294c63e9 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 28 Apr 2014 15:28:46 +0200 Subject: [FIX] web test suite: manually fetch registry bzr revid: fme@openerp.com-20140428132846-k8ofnlsse4s28jpr --- addons/web/controllers/testing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 60702a6abfe..34a0a15427f 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -7,6 +7,7 @@ import json import operator import os +import openerp from mako.template import Template from openerp.modules import module from openerp import http @@ -91,8 +92,6 @@ class TestRunnerController(http.Controller): @http.route('/web/tests', type='http', auth="none") def index(self, mod=None, **kwargs): - request.params['db'] = request.params.get('source') - ensure_db() ms = module.get_modules() manifests = dict( (name, desc) @@ -138,7 +137,11 @@ class TestRunnerController(http.Controller): ] def bundle(xmlid): - return request.render(xmlid, lazy=False) + dbname = request.params['source'] + registry = openerp.registry(dbname) + view_obj = registry["ir.ui.view"] + uid = openerp.SUPERUSER_ID + return view_obj.render(registry.cursor(), uid, xmlid, context=request.context) return TESTING.render(bundle=bundle, files=files, dependencies=json.dumps( [name for name in sorted_mods -- cgit v1.2.3 From dde0c9324bda2aff24a832ace320f23379d1ad07 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Mon, 28 Apr 2014 20:24:51 +0200 Subject: [IMP] Convered qunit test suite to template bzr revid: fme@openerp.com-20140428182451-u4mgen9669gnldva --- addons/web/controllers/testing.py | 172 -------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 addons/web/controllers/testing.py (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py deleted file mode 100644 index 34a0a15427f..00000000000 --- a/addons/web/controllers/testing.py +++ /dev/null @@ -1,172 +0,0 @@ -# coding=utf-8 -# -*- encoding: utf-8 -*- - -import glob -import itertools -import json -import operator -import os - -import openerp -from mako.template import Template -from openerp.modules import module -from openerp import http -from openerp.addons.web.controllers.main import ensure_db -from openerp.http import request - -from .main import module_topological_sort - -NOMODULE_TEMPLATE = Template(u""" - - - - - OpenERP Testing - - -
- -
    - % for name, module in modules: -
  • ${name}
  • - % endfor -
-
- - -""", default_filters=['h']) -NOTFOUND = Template(u""" -

Unable to find the module [${module}], please check that the module - name is correct and the module is on OpenERP's path.

-<< Back to tests -""", default_filters=['h']) -TESTING = Template(u""" - -<%def name="to_path(module, p)">/${module}/${p} - - - - OpenERP Web Tests - - - - - - - - -
-
- - -${bundle('web.assets_backend') | n} -% for module, jss, tests, templates in files: - % for js in jss: - % if not js.endswith('/apps.js'): - - % endif - % endfor - % if tests or templates: - - % endif - % if tests: - % for test in tests: - - % endfor - % endif -% endfor - -""", default_filters=['h']) - -class TestRunnerController(http.Controller): - - @http.route('/web/tests', type='http', auth="none") - def index(self, mod=None, **kwargs): - ms = module.get_modules() - manifests = dict( - (name, desc) - for name, desc in zip(ms, map(self.load_manifest, ms)) - if desc # remove not-actually-openerp-modules - ) - - if not mod: - return NOMODULE_TEMPLATE.render(modules=( - (manifest['name'], name) - for name, manifest in manifests.iteritems() - if any(testfile.endswith('.js') - for testfile in manifest['test']) - )) - sorted_mods = module_topological_sort(dict( - (name, manifest.get('depends', [])) - for name, manifest in manifests.iteritems() - )) - # to_load and to_test should be zippable lists of the same length. - # A falsy value in to_test indicate nothing to test at that index (just - # load the corresponding part of to_load) - to_test = sorted_mods - if mod != '*': - if mod not in manifests: - return request.not_found(NOTFOUND.render(module=mod)) - idx = sorted_mods.index(mod) - to_test = [None] * len(sorted_mods) - to_test[idx] = mod - - tests_candicates = [ - filter(lambda path: path.endswith('.js'), - manifests[mod]['test'] if mod else []) - for mod in to_test] - # remove trailing test-less modules - tests = reversed(list( - itertools.dropwhile( - operator.not_, - reversed(tests_candicates)))) - - files = [ - (mod, manifests[mod]['js'], tests, manifests[mod]['qweb']) - for mod, tests in itertools.izip(sorted_mods, tests) - ] - - def bundle(xmlid): - dbname = request.params['source'] - registry = openerp.registry(dbname) - view_obj = registry["ir.ui.view"] - uid = openerp.SUPERUSER_ID - return view_obj.render(registry.cursor(), uid, xmlid, context=request.context) - - return TESTING.render(bundle=bundle, files=files, dependencies=json.dumps( - [name for name in sorted_mods - if module.get_module_resource(name, 'static') - # TODO fme: find a way to detect modules with js bundles - # if manifests[name]['js'] - ])) - - - def load_manifest(self, name): - manifest = module.load_information_from_description_file(name) - if manifest: - path = module.get_module_path(name) - manifest['js'] = list( - self.expand_patterns(path, manifest.get('js', []))) - manifest['test'] = list( - self.expand_patterns(path, manifest.get('test', []))) - manifest['qweb'] = list( - self.expand_patterns(path, manifest.get('qweb', []))) - return manifest - - def expand_patterns(self, root, patterns): - for pattern in patterns: - normalized_pattern = os.path.normpath(os.path.join(root, pattern)) - for path in glob.glob(normalized_pattern): - # replace OS path separators (from join & normpath) by URI ones - yield path[len(root):].replace(os.path.sep, '/') - -- cgit v1.2.3