Env._finalize_core() now also loads config from Env.conf_default

This commit is contained in:
Jason Gerard DeRose 2008-10-27 01:09:53 -06:00
parent 28dd8e74bd
commit 25a7df9615
2 changed files with 12 additions and 0 deletions
ipalib
tests/test_ipalib

View File

@ -203,6 +203,8 @@ class Env(object):
self.__doing('_finalize_core')
self.__do_if_not_done('_bootstrap')
self._merge_config(self.conf)
if self.conf_default != self.conf:
self._merge_config(self.conf_default)
if 'in_server' not in self:
self.in_server = (self.context == 'server')
if 'log' not in self:

View File

@ -175,6 +175,14 @@ no = fALse
number = 42
"""
# A default config file to make sure it does not overwrite the explicit one
config_default = """
[global]
yes = Hello
not_in_other = foo_bar
"""
class test_Env(ClassChecker):
"""
@ -328,6 +336,7 @@ class test_Env(ClassChecker):
for key in ('yes', 'no', 'number'):
assert key not in o
home.write(config_good, '.ipa', 'server.conf')
home.write(config_default, '.ipa', 'default.conf')
o._finalize_core()
assert o.in_tree is True
assert o.context == 'server'
@ -336,6 +345,7 @@ class test_Env(ClassChecker):
assert o.yes is True
assert o.no is False
assert o.number == 42
assert o.not_in_other == 'foo_bar'
# Test using DEFAULT_CONFIG:
defaults = dict(constants.DEFAULT_CONFIG)