Merge "Log warning when --boolean-key and --key are used"

This commit is contained in:
Jenkins 2015-03-03 08:37:44 +00:00 committed by Gerrit Code Review
commit 752646a4ba
2 changed files with 13 additions and 0 deletions

View File

@ -339,6 +339,10 @@ def main(argv=sys.argv):
OS_CONFIG_FILES_PATH_OLD)
opts.metadata = load_list_from_json(OS_CONFIG_FILES_PATH_OLD)
if opts.key and opts.boolean_key:
logger.warning('--key is not compatible with --boolean-key.'
' --boolean-key ignored.')
try:
if opts.templates is None:
raise exc.ConfigException('missing option --templates')

View File

@ -210,6 +210,15 @@ class TestRunOSConfigApplier(testtools.TestCase):
self.path, '--boolean-key', 'x'])
self.assertEqual(-1, rcode)
def test_boolean_key_and_key(self):
rcode = apply_config.main(['os-apply-config', '--metadata',
self.path, '--boolean-key', 'btrue',
'--key', 'x'])
self.assertEqual(0, rcode)
self.stdout.seek(0)
self.assertEqual(self.stdout.read().strip(), 'foo')
self.assertIn('--boolean-key ignored', self.logger.output)
def test_os_config_files(self):
with tempfile.NamedTemporaryFile() as fake_os_config_files:
with tempfile.NamedTemporaryFile() as fake_config: