[FIX] Fix the yml test with option --test-file.

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
This commit is contained in:
Kersten Jeremy 2014-03-19 11:48:47 +01:00
parent 1225c8b530
commit 903270996f
1 changed files with 9 additions and 2 deletions

View 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)