From 3909d1ff0218203755f554eba8ee2a86dbd1405c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 22 Nov 2012 12:16:28 +0100 Subject: [ADD] a bunch of eval domain and context tests bzr revid: xmo@openerp.com-20121122111628-4khivcp97xoy121i --- addons/web/controllers/testing.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 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 3c7c4899b6c..b8e3da8ce24 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -11,7 +11,7 @@ from mako.template import Template from openerp.modules import module from .main import module_topological_sort -from ..http import Controller, httprequest +from .. import http, nonliterals NOMODULE_TEMPLATE = Template(u""" @@ -82,10 +82,22 @@ TESTING = Template(u""" """) -class TestRunnerController(Controller): +nonliteral_test_contexts = [ + "{'default_opportunity_id': active_id, 'default_duration': 1.0, 'lng': lang}", +] +nonliteral_test_domains = [ + "['|', '&', ('date', '!=', False), ('date', '<=', time.strftime('%Y-%m-%d')), ('is_overdue_quantity', '=', True)]", + "[('company_id', '=', context.get('company_id',False))]", + "[('year','=',time.strftime('%Y'))]", + "[('state','=','draft'),('date_order','<',time.strftime('%Y-%m-%d %H:%M:%S'))]", + "[('state','!=','cancel'),('opening_date','>',datetime.date.today().strftime('%Y-%m-%d'))]", + "[('type','=','in'),('day','<=', time.strftime('%Y-%m-%d')),('day','>',(datetime.date.today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]", +] + +class TestRunnerController(http.Controller): _cp_path = '/web/tests' - @httprequest + @http.httprequest def index(self, req, mod=None, **kwargs): ms = module.get_modules() manifests = dict( @@ -142,6 +154,13 @@ class TestRunnerController(Controller): if module.get_module_resource(name, 'static') if manifests[name]['js']]), db_info=json.dumps(db_info)) + @http.jsonrequest + def load_context(self, req, index): + return nonliterals.Context(req.session, nonliteral_test_contexts[index]) + @http.jsonrequest + def load_domain(self, req, index): + return nonliterals.Domain(req.session, nonliteral_test_domains[index]) + def load_manifest(self, name): manifest = module.load_information_from_description_file(name) if manifest: -- cgit v1.2.3 From 6b2b2d889c94b0cbab5fbe14a4555f4c8dbe179c Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 23 Nov 2012 12:49:23 +0100 Subject: [IMP] move nonliteral domains and contexts to JS test case bzr revid: xmo@openerp.com-20121123114923-t4047w6jztria91x --- addons/web/controllers/testing.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index b8e3da8ce24..5c7fdf46e1d 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -82,18 +82,6 @@ TESTING = Template(u""" """) -nonliteral_test_contexts = [ - "{'default_opportunity_id': active_id, 'default_duration': 1.0, 'lng': lang}", -] -nonliteral_test_domains = [ - "['|', '&', ('date', '!=', False), ('date', '<=', time.strftime('%Y-%m-%d')), ('is_overdue_quantity', '=', True)]", - "[('company_id', '=', context.get('company_id',False))]", - "[('year','=',time.strftime('%Y'))]", - "[('state','=','draft'),('date_order','<',time.strftime('%Y-%m-%d %H:%M:%S'))]", - "[('state','!=','cancel'),('opening_date','>',datetime.date.today().strftime('%Y-%m-%d'))]", - "[('type','=','in'),('day','<=', time.strftime('%Y-%m-%d')),('day','>',(datetime.date.today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]", -] - class TestRunnerController(http.Controller): _cp_path = '/web/tests' @@ -154,13 +142,6 @@ class TestRunnerController(http.Controller): if module.get_module_resource(name, 'static') if manifests[name]['js']]), db_info=json.dumps(db_info)) - @http.jsonrequest - def load_context(self, req, index): - return nonliterals.Context(req.session, nonliteral_test_contexts[index]) - @http.jsonrequest - def load_domain(self, req, index): - return nonliterals.Domain(req.session, nonliteral_test_domains[index]) - def load_manifest(self, name): manifest = module.load_information_from_description_file(name) if manifest: -- cgit v1.2.3 From 4a5cb1ebc478cb650a2bf33081f101e4f74bc6fe Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 26 Nov 2012 15:05:25 +0100 Subject: [REM] EVALPOCALYPSE PART 2: no more python-side eval trigger an error if a nonliteral context is pushed to the server (through a new object_hook) bzr revid: xmo@openerp.com-20121126140525-ni2x5m56upss610b --- addons/web/controllers/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/controllers/testing.py') diff --git a/addons/web/controllers/testing.py b/addons/web/controllers/testing.py index 5c7fdf46e1d..86940f41583 100644 --- a/addons/web/controllers/testing.py +++ b/addons/web/controllers/testing.py @@ -11,7 +11,7 @@ from mako.template import Template from openerp.modules import module from .main import module_topological_sort -from .. import http, nonliterals +from .. import http NOMODULE_TEMPLATE = Template(u""" -- cgit v1.2.3