From 0568cbe53c0a2134c1faa26030f726f74207f5df Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Sun, 4 Jul 2010 15:49:37 +0200 Subject: [PATCH] args for test bzr revid: fp@tinyerp.com-20100704134937-w4jlfqya638trpi2 --- bin/openerp-server.py | 11 +++++++++-- bin/pooler.py | 5 +++-- bin/tools/config.py | 5 +++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/openerp-server.py b/bin/openerp-server.py index 4fbebb84490..c56977fe1f0 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -113,8 +113,15 @@ if not ( tools.config["stop_after_init"] or \ service.netrpc_server.init_servers() if tools.config['db_name']: - for db in tools.config['db_name'].split(','): - pooler.get_db_and_pool(db, update_module=tools.config['init'] or tools.config['update']) + for dbname in tools.config['db_name'].split(','): + db,pool = pooler.get_db_and_pool(dbname, update_module=tools.config['init'] or tools.config['update'], pooljobs=False) + if tools.config["test-file"]: + logger.notifyChannel("init", netsvc.LOG_INFO, + 'loading test file %s' % (tools.config["test-file"],)) + cr = db.cursor() + tools.convert_yaml_import(cr, 'base', file(tools.config["test-file"]), {}, 'test', True) + cr.rollback() + pool.get('ir.cron')._poolJobs(db.dbname) #---------------------------------------------------------- # translation stuff diff --git a/bin/pooler.py b/bin/pooler.py index e0a0ff22d7c..d0f38836504 100644 --- a/bin/pooler.py +++ b/bin/pooler.py @@ -21,7 +21,7 @@ pool_dic = {} -def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False): +def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False, pooljobs=True): if not status: status={} @@ -50,7 +50,8 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False) import report report.interface.register_all(db) - pool.get('ir.cron')._poolJobs(db.dbname) + if pooljobs: + pool.get('ir.cron')._poolJobs(db.dbname) return db, pool diff --git a/bin/tools/config.py b/bin/tools/config.py index cbabb3d0cab..85c7f398b62 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -82,6 +82,7 @@ class configmanager(object): 'login_message': False, 'list_db' : True, 'timezone' : False, # to override the default TZ + 'test-file' : False, 'test-disable' : False, 'test-commit' : False, } @@ -143,6 +144,7 @@ class configmanager(object): # Testing Group group = optparse.OptionGroup(parser, "Testing Configuration") + group.add_option("--test-file", dest="test_file", help="Launch a YML test file.") group.add_option("--test-disable", action="store_true", dest="test_disable", default=False, help="Disable loading test files.") group.add_option("--test-commit", action="store_true", dest="test_commit", @@ -293,6 +295,7 @@ class configmanager(object): self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {} self.options["demo"] = not opt.without_demo and self.options['init'] or {} + self.options["test-file"] = opt.test_file self.options["test-disable"] = opt.test_disable self.options["test-commit"] = opt.test_commit self.options['update'] = opt.update and dict.fromkeys(opt.update.split(','), 1) or {} @@ -468,5 +471,3 @@ config = configmanager() # other python executables without parsing *their* args. config.parse_config() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: -