test: make enforce_type=True in CONF.set_override

Method CONF.set_override to change config option's
value with designated value in unit test, but never check if the
designated vaule is valid. Each config option has a type like strOpt,
BoolOpt, etc. StrOpt with parameter choices only allows values in set
of choices. In short word, 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.
This commit also fixes violations.

Note: We can't set enforce_type=True by default in oslo.config now, it
may break all project's unit test. We can switch enforce_type=True by
default when all project fix violations like this commit.

Related-Bug: #1517839

Depends-On: I42ceeccf59111057b5a92c849c9bb5f83255b324

Change-Id: Iffce1b62625ac2a6b00547e3791b76d289066514
This commit is contained in:
ChangBo Guo(gcb) 2015-11-19 19:03:01 +08:00
parent 2964411e92
commit 64b9dc3140
1 changed files with 1 additions and 1 deletions

View File

@ -40,7 +40,7 @@ class SaharaTestCase(base.BaseTestCase):
tenant_name=tenant_name, **kwargs))
def override_config(self, name, override, group=None):
main.CONF.set_override(name, override, group)
main.CONF.set_override(name, override, group, enforce_type=True)
self.addCleanup(main.CONF.clear_override, name, group)