[IMP] support for lxml <2.3.1
[odoo/odoo.git] / openerp / tools / test_config.py
1 # -*- coding: utf-8 -*-
2
3 """ Tests for the configuration file/command-line arguments. """
4
5 # This test should be run from its directory.
6
7 # TODO A configmanager object cannot parse multiple times a config file
8 # and/or the command line, preventing to 'reload' a configuration.
9
10 import os
11
12 import config
13
14 config_file_00 = os.path.join(os.path.dirname(__file__),'test-config-values-00.conf')
15
16 # 1. No config file, no command-line arguments (a.k.a. default values)
17
18 conf = config.configmanager()
19 conf.parse_config()
20
21 assert conf['osv_memory_age_limit'] == 1.0
22 assert os.path.join(conf['root_path'], 'addons') == conf['addons_path']
23
24 # 2. No config file, some command-line arguments
25
26 conf = config.configmanager()
27 # mess with the optparse.Option definition to allow an invalid path
28 conf.casts['addons_path'].action = 'store'
29 conf.parse_config(['--addons-path=/xyz/dont-exist', '--osv-memory-age-limit=2.3'])
30
31 assert conf['osv_memory_age_limit'] == 2.3
32 assert conf['addons_path'] == '/xyz/dont-exist'
33
34 # 3. Config file, no command-line arguments
35
36 conf = config.configmanager()
37 conf.parse_config(['-c', config_file_00])
38
39 assert conf['osv_memory_age_limit'] == 3.4
40
41 # 4. Config file, and command-line arguments
42
43 conf = config.configmanager()
44 conf.parse_config(['-c', config_file_00, '--osv-memory-age-limit=2.3'])
45
46 assert conf['osv_memory_age_limit'] == 2.3
47
48 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: