[FIX] Fix the yml test with option --test-file.
authorKersten Jeremy <jke@openerp.com>
Wed, 19 Mar 2014 10:48:47 +0000 (11:48 +0100)
committerKersten Jeremy <jke@openerp.com>
Wed, 19 Mar 2014 10:48:47 +0000 (11:48 +0100)
1 -
There was a confusing between kind and mode.
Due to the mode 'test', there are many part of code who was not executed.
The right value is kind='test', and arbitrary mode='init' (or 'update')

2 -
The yml test was always roolbacked, without check that command line had '--test-commit'.
It's has been fixed, now we check if param --test-commit is existing, else we roolback the transaction.

Rem for forward: function in trunk=saas-4 has been moved in : openerp/service/server.py - def load_test_file_yml

bzr revid: jke@openerp.com-20140319104847-6r2c70gapocn2wxq

openerp/cli/server.py

index 943ce9a..ec5516a 100644 (file)
@@ -105,8 +105,15 @@ def run_test_file(dbname, test_file):
         db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=config['init'] or config['update'])
         cr = db.cursor()
         _logger.info('loading test file %s', test_file)
-        openerp.tools.convert_yaml_import(cr, 'base', file(test_file), 'test', {}, 'test', True)
-        cr.rollback()
+        openerp.tools.convert_yaml_import(cr, 'base', file(test_file), 'test', {}, 'init')
+
+        if config['test_commit']:
+            _logger.info('test %s has been commited', test_file)
+            cr.commit()
+        else:
+            _logger.info('test %s has been rollbacked', test_file)
+            cr.rollback()
+
         cr.close()
     except Exception:
         _logger.exception('Failed to initialize database `%s` and run test file `%s`.', dbname, test_file)