Fix CLI Missing Auth Error Format

Fixed formatting and updated unit tests.
Python should be underscore.  User should see hyphen.

Change-Id: Iab940e4bff016b83d250aeb68df7f7382810679a
This commit is contained in:
One-Fine-Day 2018-01-08 11:12:37 -06:00
parent 585870080a
commit 17bcb54ecd
2 changed files with 9 additions and 8 deletions

View File

@ -167,10 +167,11 @@ class CliAction(AbstractCliAction):
if self.auth_vars[var] is None:
err_txt.append(
'Missing the required authorization variable: '
'--os_{}'.format(var))
'--os-{}'.format(var.replace('_', '-')))
if err_txt:
for var in self.auth_vars:
if (self.auth_vars.get(var) is None and
var not in required_auth_vars):
err_txt.append('- Also not set: --os_{}'.format(var))
err_txt.append('- Also not set: --os-{}'.format(
var.replace('_', '-')))
raise AuthValuesError(diagnostic='\n'.join(err_txt))

View File

@ -42,9 +42,9 @@ def test_validate_auth_vars_missing_required():
try:
action.validate_auth_vars()
except AuthValuesError as ex:
assert 'os_auth_url' in ex.diagnostic
assert 'os_username' not in ex.diagnostic
assert 'os_password' not in ex.diagnostic
assert 'os-auth-url' in ex.diagnostic
assert 'os-username' not in ex.diagnostic
assert 'os-password' not in ex.diagnostic
raise
@ -63,7 +63,7 @@ def test_validate_auth_vars_missing_required_and_others():
try:
action.validate_auth_vars()
except AuthValuesError as ex:
assert 'os_auth_url' in ex.diagnostic
assert 'os_username' in ex.diagnostic
assert 'os_password' not in ex.diagnostic
assert 'os-auth-url' in ex.diagnostic
assert 'os-username' in ex.diagnostic
assert 'os-password' not in ex.diagnostic
raise