summaryrefslogtreecommitdiff
path: root/odoo/modules
diff options
context:
space:
mode:
authormge-odoo <mge@odoo.com>2017-02-07 17:23:13 +0100
committerRaphael Collet <rco@openerp.com>2017-02-08 16:13:01 +0100
commitff2f188d200689e59bddcdcb441df8be4e8319a4 (patch)
tree56b319ea617a6b7c08467f3da66e028a5c753a97 /odoo/modules
parent854759b5b12dad26cbc68a69d4a41c856ff298d5 (diff)
[IMP] tests: allow post-install tests to play real transactions
Move the post-install tests execution outside `Registry.new`, and add a flag on class `HttpCase` to enable/disable the registry "test mode". This allows a test to run actual transactions that will reload the registry, which may be used to test the creation of `ir.model` instances, etc.
Diffstat (limited to 'odoo/modules')
-rw-r--r--odoo/modules/loading.py16
-rw-r--r--odoo/modules/registry.py1
2 files changed, 4 insertions, 13 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index e9744844841..0f9987f62eb 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -19,8 +19,7 @@ import odoo.modules.registry
import odoo.tools as tools
from odoo import api, SUPERUSER_ID
-from odoo.modules.module import adapt_version, initialize_sys_path, \
- load_openerp_module, runs_post_install
+from odoo.modules.module import adapt_version, initialize_sys_path, load_openerp_module
_logger = logging.getLogger(__name__)
_test_logger = logging.getLogger('odoo.tests')
@@ -416,18 +415,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
for model in env.values():
model._register_hook()
- # STEP 9: Run the post-install tests
+ # STEP 9: save installed/updated modules for post-install tests
+ registry.updated_modules += processed_modules
cr.commit()
- t0 = time.time()
- t0_sql = odoo.sql_db.sql_counter
- if odoo.tools.config['test_enable']:
- if update_module:
- cr.execute("SELECT name FROM ir_module_module WHERE state='installed' and name = ANY(%s)", (processed_modules,))
- else:
- cr.execute("SELECT name FROM ir_module_module WHERE state='installed'")
- for module_name in cr.fetchall():
- report.record_result(odoo.modules.module.run_unit_tests(module_name[0], cr.dbname, position=runs_post_install))
- _logger.log(25, "All post-tested in %.2fs, %s queries", time.time() - t0, odoo.sql_db.sql_counter - t0_sql)
finally:
cr.close()
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 6e5378d33c8..7bfacb700fb 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -109,6 +109,7 @@ class Registry(Mapping):
# modules fully loaded (maintained during init phase by `loading` module)
self._init_modules = set()
+ self.updated_modules = [] # installed/updated modules
self.db_name = db_name
self._db = odoo.sql_db.db_connect(db_name)