Test: make enforce_type=True in CONF.set_override

each config option has limitation for type and value.
In production code, oslo.conf can ensure user's input
is valid, but in unit test, test methods can pass if
we use method CONF.set_override without parameter
enforce_type=True even we pass wrong type or wrong
value to config option. This commit makes sure calling
method CONF.set_override with enforce_type=True.

Change-Id: I52fdc7ed9f74f80814fbafd00625dcdd5597ba0e
Closes-bug: #1517839
This commit is contained in:
LiuNanke 2016-01-03 20:35:00 +08:00
parent 3f1450d57e
commit 9ec0f3317b
2 changed files with 3 additions and 2 deletions

View File

@ -165,7 +165,7 @@ class TestDatabaseDomainConfigs(unit.TestCase):
# Now turn off using database domain configuration and check that the
# default config file values are now seen instead of the overrides.
CONF.set_override('domain_configurations_from_database', False,
'identity')
'identity', enforce_type=True)
domain_config = identity.DomainConfigs()
domain_config.setup_domain_drivers(fake_standard_driver,
self.resource_api)

View File

@ -71,7 +71,8 @@ class AppServer(fixtures.Fixture):
def _update_config_opt(self):
"""Updates the config with the actual port used."""
opt_name = self._get_config_option_for_section_name()
CONF.set_override(opt_name, self.port, group='eventlet_server')
CONF.set_override(opt_name, self.port, group='eventlet_server',
enforce_type=True)
def _get_config_option_for_section_name(self):
"""Maps Paster config section names to port option names."""