From 17bcb54ecde62f69bdd1db73f615dc575fd80168 Mon Sep 17 00:00:00 2001 From: One-Fine-Day Date: Mon, 8 Jan 2018 11:12:37 -0600 Subject: [PATCH] Fix CLI Missing Auth Error Format Fixed formatting and updated unit tests. Python should be underscore. User should see hyphen. Change-Id: Iab940e4bff016b83d250aeb68df7f7382810679a --- shipyard_client/cli/action.py | 5 +++-- .../tests/unit/cli/test_auth_validations.py | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/shipyard_client/cli/action.py b/shipyard_client/cli/action.py index 4b24860e..6dde3865 100644 --- a/shipyard_client/cli/action.py +++ b/shipyard_client/cli/action.py @@ -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)) diff --git a/shipyard_client/tests/unit/cli/test_auth_validations.py b/shipyard_client/tests/unit/cli/test_auth_validations.py index 5a489ddc..ab8ab147 100644 --- a/shipyard_client/tests/unit/cli/test_auth_validations.py +++ b/shipyard_client/tests/unit/cli/test_auth_validations.py @@ -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