diff options
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/identity/client.py | 7 | ||||
| -rw-r--r-- | openstackclient/identity/common.py | 35 | ||||
| -rw-r--r-- | openstackclient/tests/compute/v2/test_flavor.py | 33 |
3 files changed, 31 insertions, 44 deletions
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py index 1868b224..be7b643f 100644 --- a/openstackclient/identity/client.py +++ b/openstackclient/identity/client.py @@ -19,6 +19,7 @@ from keystoneclient.v2_0 import client as identity_client_v2 from osc_lib import utils from openstackclient.api import auth +from openstackclient.i18n import _ LOG = logging.getLogger(__name__) @@ -65,9 +66,9 @@ def build_option_parser(parser): '--os-identity-api-version', metavar='<identity-api-version>', default=utils.env('OS_IDENTITY_API_VERSION'), - help='Identity API version, default=' + - DEFAULT_API_VERSION + - ' (Env: OS_IDENTITY_API_VERSION)') + help=_('Identity API version, default=%s ' + '(Env: OS_IDENTITY_API_VERSION)') % DEFAULT_API_VERSION, + ) return auth.build_auth_plugins_option_parser(parser) diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py index 16ee63e1..cd767d2f 100644 --- a/openstackclient/identity/common.py +++ b/openstackclient/identity/common.py @@ -23,6 +23,8 @@ from keystoneclient.v3 import users from osc_lib import exceptions from osc_lib import utils +from openstackclient.i18n import _ + def find_service(identity_client, name_type_or_id): """Find a service by id, name or type.""" @@ -37,14 +39,12 @@ def find_service(identity_client, name_type_or_id): # FIXME(dtroyer): This exception should eventually come from # common client exceptions except identity_exc.NotFound: - msg = ("No service with a type, name or ID of '%s' exists." - % name_type_or_id) - raise exceptions.CommandError(msg) + msg = _("No service with a type, name or ID of '%s' exists.") + raise exceptions.CommandError(msg % name_type_or_id) except identity_exc.NoUniqueMatch: - msg = ("Multiple service matches found for '%s', " - "use an ID to be more specific." - % name_type_or_id) - raise exceptions.CommandError(msg) + msg = _("Multiple service matches found for '%s', " + "use an ID to be more specific.") + raise exceptions.CommandError(msg % name_type_or_id) def _get_domain_id_if_requested(identity_client, domain_name_or_id): @@ -131,9 +131,9 @@ def add_user_domain_option_to_parser(parser): parser.add_argument( '--user-domain', metavar='<user-domain>', - help=('Domain the user belongs to (name or ID). ' - 'This can be used in case collisions between user names ' - 'exist.') + help=_('Domain the user belongs to (name or ID). ' + 'This can be used in case collisions between user names ' + 'exist.'), ) @@ -141,9 +141,9 @@ def add_group_domain_option_to_parser(parser): parser.add_argument( '--group-domain', metavar='<group-domain>', - help=('Domain the group belongs to (name or ID). ' - 'This can be used in case collisions between group names ' - 'exist.') + help=_('Domain the group belongs to (name or ID). ' + 'This can be used in case collisions between group names ' + 'exist.'), ) @@ -151,9 +151,9 @@ def add_project_domain_option_to_parser(parser): parser.add_argument( '--project-domain', metavar='<project-domain>', - help=('Domain the project belongs to (name or ID). ' - 'This can be used in case collisions between project names ' - 'exist.') + help=_('Domain the project belongs to (name or ID). ' + 'This can be used in case collisions between project names ' + 'exist.'), ) @@ -162,5 +162,6 @@ def add_inherited_option_to_parser(parser): '--inherited', action='store_true', default=False, - help=('Specifies if the role grant is inheritable to the sub projects') + help=_('Specifies if the role grant is inheritable to the sub ' + 'projects'), ) diff --git a/openstackclient/tests/compute/v2/test_flavor.py b/openstackclient/tests/compute/v2/test_flavor.py index 8ce7bb27..27b53bbf 100644 --- a/openstackclient/tests/compute/v2/test_flavor.py +++ b/openstackclient/tests/compute/v2/test_flavor.py @@ -645,6 +645,8 @@ class TestFlavorUnset(TestFlavor): result = self.cmd.take_action(parsed_args) self.flavors_mock.find.assert_called_with(name=parsed_args.flavor, is_public=None) + self.flavor.unset_keys.assert_called_with(['property']) + self.flavor_access_mock.remove_tenant_access.assert_not_called() self.assertIsNone(result) def test_flavor_unset_project(self): @@ -661,24 +663,14 @@ class TestFlavorUnset(TestFlavor): result = self.cmd.take_action(parsed_args) self.assertIsNone(result) + self.flavors_mock.find.assert_called_with(name=parsed_args.flavor, + is_public=None) self.flavor_access_mock.remove_tenant_access.assert_called_with( self.flavor.id, identity_fakes.project_id, ) - - def test_flavor_unset_no_project(self): - arglist = [ - '--project', '', - self.flavor.id, - ] - verifylist = [ - ('project', ''), - ('flavor', self.flavor.id), - ] - - parsed_args = self.check_parser(self.cmd, arglist, verifylist) - self.assertRaises(exceptions.CommandError, self.cmd.take_action, - parsed_args) + self.flavor.unset_keys.assert_not_called() + self.assertIsNone(result) def test_flavor_unset_no_flavor(self): arglist = [ @@ -687,12 +679,8 @@ class TestFlavorUnset(TestFlavor): verifylist = [ ('project', identity_fakes.project_id), ] - - self.assertRaises(tests_utils.ParserException, - self.check_parser, - self.cmd, - arglist, - verifylist) + self.assertRaises(tests_utils.ParserException, self.check_parser, + self.cmd, arglist, verifylist) def test_flavor_unset_with_unexist_flavor(self): self.flavors_mock.get.side_effect = exceptions.NotFound(None) @@ -707,9 +695,7 @@ class TestFlavorUnset(TestFlavor): ('flavor', 'unexist_flavor'), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) - - self.assertRaises(exceptions.CommandError, - self.cmd.take_action, + self.assertRaises(exceptions.CommandError, self.cmd.take_action, parsed_args) def test_flavor_unset_nothing(self): @@ -719,7 +705,6 @@ class TestFlavorUnset(TestFlavor): verifylist = [ ('flavor', self.flavor.id), ] - parsed_args = self.check_parser(self.cmd, arglist, verifylist) self.assertRaises(exceptions.CommandError, self.cmd.take_action, parsed_args) |
