summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/compute/v2/keypair.py5
-rw-r--r--openstackclient/compute/v2/security_group.py12
-rw-r--r--openstackclient/compute/v2/server.py19
-rw-r--r--openstackclient/i18n.py31
-rw-r--r--openstackclient/identity/client.py21
-rw-r--r--openstackclient/identity/v3/domain.py11
-rw-r--r--openstackclient/identity/v3/endpoint.py44
-rw-r--r--openstackclient/network/v2/network.py3
-rw-r--r--openstackclient/shell.py55
-rw-r--r--openstackclient/tests/identity/v3/fakes.py19
-rw-r--r--openstackclient/tests/identity/v3/test_domain.py414
-rw-r--r--openstackclient/tests/identity/v3/test_endpoint.py671
12 files changed, 1244 insertions, 61 deletions
diff --git a/openstackclient/compute/v2/keypair.py b/openstackclient/compute/v2/keypair.py
index 74cf4372..22c07ef7 100644
--- a/openstackclient/compute/v2/keypair.py
+++ b/openstackclient/compute/v2/keypair.py
@@ -57,8 +57,9 @@ class CreateKeypair(show.ShowOne):
with open(os.path.expanduser(parsed_args.public_key)) as p:
public_key = p.read()
except IOError as e:
- raise exceptions.CommandError(
- "Key file %s not found: %s" % (parsed_args.public_key, e))
+ msg = "Key file %s not found: %s"
+ raise exceptions.CommandError(msg
+ % (parsed_args.public_key, e))
keypair = compute_client.keypairs.create(
parsed_args.name,
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py
index 0ba55c98..cd330857 100644
--- a/openstackclient/compute/v2/security_group.py
+++ b/openstackclient/compute/v2/security_group.py
@@ -23,6 +23,7 @@ from cliff import command
from cliff import lister
from cliff import show
+from keystoneclient.openstack.common.apiclient import exceptions as ksc_exc
from novaclient.v1_1 import security_group_rules
from openstackclient.common import parseractions
from openstackclient.common import utils
@@ -150,10 +151,15 @@ class ListSecurityGroup(lister.Lister):
search = {'all_tenants': parsed_args.all_projects}
data = compute_client.security_groups.list(search_opts=search)
- projects = self.app.client_manager.identity.projects.list()
project_hash = {}
- for project in projects:
- project_hash[project.id] = project
+ try:
+ projects = self.app.client_manager.identity.projects.list()
+ except ksc_exc.Forbidden:
+ # This fails when the user is not an admin, just move along
+ pass
+ else:
+ for project in projects:
+ project_hash[project.id] = project
return (column_headers,
(utils.get_item_properties(
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index a4ed6fa4..ec7f212d 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -175,7 +175,7 @@ class AddServerSecurityGroup(command.Command):
parsed_args.group,
)
- server.add_security_group(security_group)
+ server.add_security_group(security_group.name)
return
@@ -300,19 +300,22 @@ class CreateServer(show.ShowOne):
raise exceptions.CommandError("Can't open '%s': %s" % (src, e))
if parsed_args.min > parsed_args.max:
- raise exceptions.CommandError("min instances should be <= "
- "max instances")
+ msg = "min instances should be <= max instances"
+ raise exceptions.CommandError(msg)
if parsed_args.min < 1:
- raise exceptions.CommandError("min instances should be > 0")
+ msg = "min instances should be > 0"
+ raise exceptions.CommandError(msg)
if parsed_args.max < 1:
- raise exceptions.CommandError("max instances should be > 0")
+ msg = "max instances should be > 0"
+ raise exceptions.CommandError(msg)
userdata = None
if parsed_args.user_data:
try:
userdata = open(parsed_args.user_data)
except IOError as e:
- raise exceptions.CommandError("Can't open '%s': %s" %
+ msg = "Can't open '%s': %s"
+ raise exceptions.CommandError(msg %
(parsed_args.user_data, e))
block_device_mapping = dict(v.split('=', 1)
@@ -1082,8 +1085,8 @@ class SetServer(command.Command):
if p1 == p2:
server.change_password(p1)
else:
- raise exceptions.CommandError(
- "Passwords do not match, password unchanged")
+ msg = "Passwords do not match, password unchanged"
+ raise exceptions.CommandError(msg)
class ShowServer(show.ShowOne):
diff --git a/openstackclient/i18n.py b/openstackclient/i18n.py
new file mode 100644
index 00000000..bd52d648
--- /dev/null
+++ b/openstackclient/i18n.py
@@ -0,0 +1,31 @@
+# Copyright 2012-2013 OpenStack Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+from oslo import i18n
+
+_translators = i18n.TranslatorFactory(domain='openstackclient')
+
+# The primary translation function using the well-known name "_"
+_ = _translators.primary
+
+# Translators for log levels.
+#
+# The abbreviated names are meant to reflect the usual use of a short
+# name like '_'. The "L" is for "log" and the other letter comes from
+# the level.
+_LI = _translators.log_info
+_LW = _translators.log_warning
+_LE = _translators.log_error
+_LC = _translators.log_critical
diff --git a/openstackclient/identity/client.py b/openstackclient/identity/client.py
index 172910f5..820d08cb 100644
--- a/openstackclient/identity/client.py
+++ b/openstackclient/identity/client.py
@@ -80,6 +80,27 @@ def make_client(instance):
return client
+def build_option_parser(parser):
+ """Hook to add global options"""
+ parser.add_argument(
+ '--os-identity-api-version',
+ metavar='<identity-api-version>',
+ default=utils.env(
+ 'OS_IDENTITY_API_VERSION',
+ default=DEFAULT_IDENTITY_API_VERSION),
+ help='Identity API version, default=' +
+ DEFAULT_IDENTITY_API_VERSION +
+ ' (Env: OS_IDENTITY_API_VERSION)')
+ parser.add_argument(
+ '--os-trust-id',
+ metavar='<trust-id>',
+ default=utils.env('OS_TRUST_ID'),
+ help='Trust ID to use when authenticating. '
+ 'This can only be used with Keystone v3 API '
+ '(Env: OS_TRUST_ID)')
+ return parser
+
+
class IdentityClientv2_0(identity_client_v2_0.Client):
"""Tweak the earlier client class to deal with some changes"""
def __getattr__(self, name):
diff --git a/openstackclient/identity/v3/domain.py b/openstackclient/identity/v3/domain.py
index f9763847..49397afc 100644
--- a/openstackclient/identity/v3/domain.py
+++ b/openstackclient/identity/v3/domain.py
@@ -135,13 +135,12 @@ class SetDomain(command.Command):
'--enable',
dest='enabled',
action='store_true',
- default=True,
help='Enable domain (default)',
)
enable_group.add_argument(
'--disable',
- dest='enabled',
- action='store_false',
+ dest='disabled',
+ action='store_true',
help='Disable domain',
)
return parser
@@ -156,8 +155,10 @@ class SetDomain(command.Command):
kwargs['name'] = parsed_args.name
if parsed_args.description:
kwargs['description'] = parsed_args.description
- if 'enabled' in parsed_args:
- kwargs['enabled'] = parsed_args.enabled
+ if parsed_args.enabled:
+ kwargs['enabled'] = True
+ if parsed_args.disabled:
+ kwargs['enabled'] = False
if not kwargs:
sys.stdout.write("Domain not updated, no arguments present")
diff --git a/openstackclient/identity/v3/endpoint.py b/openstackclient/identity/v3/endpoint.py
index 4ea44e7a..39798b2d 100644
--- a/openstackclient/identity/v3/endpoint.py
+++ b/openstackclient/identity/v3/endpoint.py
@@ -114,12 +114,38 @@ class ListEndpoint(lister.Lister):
log = logging.getLogger(__name__ + '.ListEndpoint')
+ def get_parser(self, prog_name):
+ parser = super(ListEndpoint, self).get_parser(prog_name)
+ parser.add_argument(
+ '--service',
+ metavar='<service>',
+ help='Filter by a specific service')
+ parser.add_argument(
+ '--interface',
+ metavar='<interface>',
+ choices=['admin', 'public', 'internal'],
+ help='Filter by a specific interface, must be admin, public or'
+ ' internal')
+ parser.add_argument(
+ '--region',
+ metavar='<region>',
+ help='Filter by a specific region')
+ return parser
+
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
identity_client = self.app.client_manager.identity
columns = ('ID', 'Region', 'Service Name', 'Service Type',
'Enabled', 'Interface', 'URL')
- data = identity_client.endpoints.list()
+ kwargs = {}
+ if parsed_args.service:
+ service = common.find_service(identity_client, parsed_args.service)
+ kwargs['service'] = service.id
+ if parsed_args.interface:
+ kwargs['interface'] = parsed_args.interface
+ if parsed_args.region:
+ kwargs['region'] = parsed_args.region
+ data = identity_client.endpoints.list(**kwargs)
for ep in data:
service = common.find_service(identity_client, ep.service_id)
@@ -165,13 +191,12 @@ class SetEndpoint(command.Command):
'--enable',
dest='enabled',
action='store_true',
- default=True,
help='Enable endpoint',
)
enable_group.add_argument(
'--disable',
- dest='enabled',
- action='store_false',
+ dest='disabled',
+ action='store_true',
help='Disable endpoint',
)
return parser
@@ -183,7 +208,8 @@ class SetEndpoint(command.Command):
parsed_args.endpoint)
if (not parsed_args.interface and not parsed_args.url
- and not parsed_args.service and not parsed_args.region):
+ and not parsed_args.service and not parsed_args.region
+ and not parsed_args.enabled and not parsed_args.disabled):
sys.stdout.write("Endpoint not updated, no arguments present")
return
@@ -192,13 +218,19 @@ class SetEndpoint(command.Command):
service = common.find_service(identity_client, parsed_args.service)
service_id = service.id
+ enabled = None
+ if parsed_args.enabled:
+ enabled = True
+ if parsed_args.disabled:
+ enabled = False
+
identity_client.endpoints.update(
endpoint.id,
service=service_id,
url=parsed_args.url,
interface=parsed_args.interface,
region=parsed_args.region,
- enabled=parsed_args.enabled
+ enabled=enabled
)
return
diff --git a/openstackclient/network/v2/network.py b/openstackclient/network/v2/network.py
index 24d71976..4ee37e26 100644
--- a/openstackclient/network/v2/network.py
+++ b/openstackclient/network/v2/network.py
@@ -208,7 +208,8 @@ class SetNetwork(command.Command):
if parsed_args.shared is not None:
body['shared'] = parsed_args.shared
if body == {}:
- raise exceptions.CommandError("Nothing specified to be set")
+ msg = "Nothing specified to be set"
+ raise exceptions.CommandError(msg)
update_method = getattr(client, "update_network")
update_method(_id, {'network': body})
return
diff --git a/openstackclient/shell.py b/openstackclient/shell.py
index a6f508e4..24804343 100644
--- a/openstackclient/shell.py
+++ b/openstackclient/shell.py
@@ -33,7 +33,6 @@ from openstackclient.common import commandmanager
from openstackclient.common import exceptions as exc
from openstackclient.common import timing
from openstackclient.common import utils
-from openstackclient.identity import client as identity_client
KEYRING_SERVICE = 'openstack'
@@ -75,6 +74,8 @@ class OpenStackShell(app.App):
version=openstackclient.__version__,
command_manager=commandmanager.CommandManager('openstack.cli'))
+ self.api_version = {}
+
# Until we have command line arguments parsed, dump any stack traces
self.dump_stack_trace = True
@@ -85,10 +86,14 @@ class OpenStackShell(app.App):
# Assume TLS host certificate verification is enabled
self.verify = True
- # Get list of extension modules
+ # Get list of base modules
self.ext_modules = clientmanager.get_extension_modules(
- 'openstack.cli.extension',
+ 'openstack.cli.base',
)
+ # Append list of extension modules
+ self.ext_modules.extend(clientmanager.get_extension_modules(
+ 'openstack.cli.extension',
+ ))
# Loop through extensions to get parser additions
for mod in self.ext_modules:
@@ -311,23 +316,6 @@ class OpenStackShell(app.App):
help="Print API call timing info",
)
- parser.add_argument(
- '--os-identity-api-version',
- metavar='<identity-api-version>',
- default=env(
- 'OS_IDENTITY_API_VERSION',
- default=identity_client.DEFAULT_IDENTITY_API_VERSION),
- help='Identity API version, default=' +
- identity_client.DEFAULT_IDENTITY_API_VERSION +
- ' (Env: OS_IDENTITY_API_VERSION)')
- parser.add_argument(
- '--os-trust-id',
- metavar='<trust-id>',
- default=utils.env('OS_TRUST_ID'),
- help='Trust ID to use when authenticating. '
- 'This can only be used with Keystone v3 API '
- '(Env: OS_TRUST_ID)')
-
return parser
def authenticate_user(self):
@@ -436,24 +424,19 @@ class OpenStackShell(app.App):
# Save default domain
self.default_domain = self.options.os_default_domain
- # Stash selected API versions for later
- self.api_version = {
- 'identity': self.options.os_identity_api_version,
- }
# Loop through extensions to get API versions
for mod in self.ext_modules:
- ver = getattr(self.options, mod.API_VERSION_OPTION, None)
- if ver:
- self.api_version[mod.API_NAME] = ver
- self.log.debug('%(name)s API version %(version)s',
- {'name': mod.API_NAME, 'version': ver})
-
- # Add the API version-specific commands
- for api in self.api_version.keys():
- version = '.v' + self.api_version[api].replace('.', '_')
- cmd_group = 'openstack.' + api.replace('-', '_') + version
- self.log.debug('command group %s', cmd_group)
- self.command_manager.add_command_group(cmd_group)
+ version_opt = getattr(self.options, mod.API_VERSION_OPTION, None)
+ if version_opt:
+ api = mod.API_NAME
+ self.api_version[api] = version_opt
+ version = '.v' + version_opt.replace('.', '_')
+ cmd_group = 'openstack.' + api.replace('-', '_') + version
+ self.command_manager.add_command_group(cmd_group)
+ self.log.debug(
+ '%(name)s API version %(version)s, cmd group %(group)s',
+ {'name': api, 'version': version_opt, 'group': cmd_group}
+ )
# Commands that span multiple APIs
self.command_manager.add_command_group(
diff --git a/openstackclient/tests/identity/v3/fakes.py b/openstackclient/tests/identity/v3/fakes.py
index 60417157..e9cda9ff 100644
--- a/openstackclient/tests/identity/v3/fakes.py
+++ b/openstackclient/tests/identity/v3/fakes.py
@@ -21,10 +21,13 @@ from openstackclient.tests import utils
domain_id = 'd1'
domain_name = 'oftheking'
+domain_description = 'domain description'
DOMAIN = {
'id': domain_id,
'name': domain_name,
+ 'description': domain_description,
+ 'enabled': True,
}
group_id = 'gr-010'
@@ -74,6 +77,20 @@ SERVICE = {
'enabled': True,
}
+endpoint_id = 'e-123'
+endpoint_url = 'http://127.0.0.1:35357'
+endpoint_region = 'RegionOne'
+endpoint_interface = 'admin'
+
+ENDPOINT = {
+ 'id': endpoint_id,
+ 'url': endpoint_url,
+ 'region': endpoint_region,
+ 'interface': endpoint_interface,
+ 'service_id': service_id,
+ 'enabled': True,
+}
+
user_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
user_name = 'paul'
user_description = 'Sir Paul'
@@ -182,6 +199,8 @@ class FakeIdentityv3Client(object):
def __init__(self, **kwargs):
self.domains = mock.Mock()
self.domains.resource_class = fakes.FakeResource(None, {})
+ self.endpoints = mock.Mock()
+ self.endpoints.resource_class = fakes.FakeResource(None, {})
self.groups = mock.Mock()
self.groups.resource_class = fakes.FakeResource(None, {})
self.oauth1 = mock.Mock()
diff --git a/openstackclient/tests/identity/v3/test_domain.py b/openstackclient/tests/identity/v3/test_domain.py
new file mode 100644
index 00000000..8dad5bcc
--- /dev/null
+++ b/openstackclient/tests/identity/v3/test_domain.py
@@ -0,0 +1,414 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import copy
+
+from openstackclient.identity.v3 import domain
+from openstackclient.tests import fakes
+from openstackclient.tests.identity.v3 import fakes as identity_fakes
+
+
+class TestDomain(identity_fakes.TestIdentityv3):
+
+ def setUp(self):
+ super(TestDomain, self).setUp()
+
+ # Get a shortcut to the DomainManager Mock
+ self.domains_mock = self.app.client_manager.identity.domains
+ self.domains_mock.reset_mock()
+
+
+class TestDomainCreate(TestDomain):
+
+ def setUp(self):
+ super(TestDomainCreate, self).setUp()
+
+ self.domains_mock.create.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = domain.CreateDomain(self.app, None)
+
+ def test_domain_create_no_options(self):
+ arglist = [
+ identity_fakes.domain_name,
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('name', identity_fakes.domain_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'name': identity_fakes.domain_name,
+ 'description': None,
+ 'enabled': True,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('description', 'enabled', 'id', 'name')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.domain_description,
+ True,
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_domain_create_description(self):
+ arglist = [
+ '--description', 'new desc',
+ identity_fakes.domain_name,
+ ]
+ verifylist = [
+ ('description', 'new desc'),
+ ('enabled', True),
+ ('name', identity_fakes.domain_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'name': identity_fakes.domain_name,
+ 'description': 'new desc',
+ 'enabled': True,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('description', 'enabled', 'id', 'name')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.domain_description,
+ True,
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_domain_create_enable(self):
+ arglist = [
+ '--enable',
+ identity_fakes.domain_name,
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('name', identity_fakes.domain_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'name': identity_fakes.domain_name,
+ 'description': None,
+ 'enabled': True,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('description', 'enabled', 'id', 'name')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.domain_description,
+ True,
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_domain_create_disable(self):
+ arglist = [
+ '--disable',
+ identity_fakes.domain_name,
+ ]
+ verifylist = [
+ ('enabled', False),
+ ('name', identity_fakes.domain_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'name': identity_fakes.domain_name,
+ 'description': None,
+ 'enabled': False,
+ }
+ self.domains_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('description', 'enabled', 'id', 'name')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.domain_description,
+ True,
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ )
+ self.assertEqual(datalist, data)
+
+
+class TestDomainDelete(TestDomain):
+
+ def setUp(self):
+ super(TestDomainDelete, self).setUp()
+
+ # This is the return value for utils.find_resource()
+ self.domains_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ )
+ self.domains_mock.delete.return_value = None
+
+ # Get the command object to test
+ self.cmd = domain.DeleteDomain(self.app, None)
+
+ def test_domain_delete(self):
+ arglist = [
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ self.domains_mock.delete.assert_called_with(
+ identity_fakes.domain_id,
+ )
+
+
+class TestDomainList(TestDomain):
+
+ def setUp(self):
+ super(TestDomainList, self).setUp()
+
+ self.domains_mock.list.return_value = [
+ fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ ),
+ ]
+
+ # Get the command object to test
+ self.cmd = domain.ListDomain(self.app, None)
+
+ def test_domain_list_no_options(self):
+ arglist = []
+ verifylist = []
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+ self.domains_mock.list.assert_called_with()
+
+ collist = ('ID', 'Name', 'Enabled', 'Description')
+ self.assertEqual(collist, columns)
+ datalist = ((
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ True,
+ identity_fakes.domain_description,
+ ), )
+ self.assertEqual(datalist, tuple(data))
+
+
+class TestDomainSet(TestDomain):
+
+ def setUp(self):
+ super(TestDomainSet, self).setUp()
+
+ self.domains_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ )
+
+ self.domains_mock.update.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = domain.SetDomain(self.app, None)
+
+ def test_domain_set_no_options(self):
+ arglist = [
+ identity_fakes.domain_name,
+ ]
+ verifylist = [
+ ('domain', identity_fakes.domain_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ self.assertNotCalled(self.domains_mock.update)
+
+ def test_domain_set_name(self):
+ arglist = [
+ '--name', 'qwerty',
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('name', 'qwerty'),
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'name': 'qwerty',
+ }
+ self.domains_mock.update.assert_called_with(
+ identity_fakes.domain_id,
+ **kwargs
+ )
+
+ def test_domain_set_description(self):
+ arglist = [
+ '--description', 'new desc',
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('description', 'new desc'),
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'description': 'new desc',
+ }
+ self.domains_mock.update.assert_called_with(
+ identity_fakes.domain_id,
+ **kwargs
+ )
+
+ def test_domain_set_enable(self):
+ arglist = [
+ '--enable',
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': True,
+ }
+ self.domains_mock.update.assert_called_with(
+ identity_fakes.domain_id,
+ **kwargs
+ )
+
+ def test_domain_set_disable(self):
+ arglist = [
+ '--disable',
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('disabled', True),
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': False,
+ }
+ self.domains_mock.update.assert_called_with(
+ identity_fakes.domain_id,
+ **kwargs
+ )
+
+
+class TestDomainShow(TestDomain):
+
+ def setUp(self):
+ super(TestDomainShow, self).setUp()
+
+ self.domains_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.DOMAIN),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = domain.ShowDomain(self.app, None)
+
+ def test_domain_show(self):
+ arglist = [
+ identity_fakes.domain_id,
+ ]
+ verifylist = [
+ ('domain', identity_fakes.domain_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+ self.domains_mock.get.assert_called_with(
+ identity_fakes.domain_id,
+ )
+
+ collist = ('description', 'enabled', 'id', 'name')
+ self.assertEqual(collist, columns)
+ datalist = (
+ identity_fakes.domain_description,
+ True,
+ identity_fakes.domain_id,
+ identity_fakes.domain_name,
+ )
+ self.assertEqual(datalist, data)
diff --git a/openstackclient/tests/identity/v3/test_endpoint.py b/openstackclient/tests/identity/v3/test_endpoint.py
new file mode 100644
index 00000000..ea05326e
--- /dev/null
+++ b/openstackclient/tests/identity/v3/test_endpoint.py
@@ -0,0 +1,671 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+import copy
+
+from openstackclient.identity.v3 import endpoint
+from openstackclient.tests import fakes
+from openstackclient.tests.identity.v3 import fakes as identity_fakes
+
+
+class TestEndpoint(identity_fakes.TestIdentityv3):
+
+ def setUp(self):
+ super(TestEndpoint, self).setUp()
+
+ # Get a shortcut to the EndpointManager Mock
+ self.endpoints_mock = self.app.client_manager.identity.endpoints
+ self.endpoints_mock.reset_mock()
+
+ # Get a shortcut to the ServiceManager Mock
+ self.services_mock = self.app.client_manager.identity.services
+ self.services_mock.reset_mock()
+
+
+class TestEndpointCreate(TestEndpoint):
+
+ def setUp(self):
+ super(TestEndpointCreate, self).setUp()
+
+ self.endpoints_mock.create.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+
+ # This is the return value for common.find_resource(service)
+ self.services_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.SERVICE),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = endpoint.CreateEndpoint(self.app, None)
+
+ def test_endpoint_create_no_options(self):
+ arglist = [
+ identity_fakes.service_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('service', identity_fakes.service_id),
+ ('interface', identity_fakes.endpoint_interface),
+ ('url', identity_fakes.endpoint_url),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'service': identity_fakes.service_id,
+ 'url': identity_fakes.endpoint_url,
+ 'interface': identity_fakes.endpoint_interface,
+ 'enabled': True,
+ 'region': None,
+ }
+
+ self.endpoints_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('enabled', 'id', 'interface', 'region', 'service_id',
+ 'service_name', 'service_type', 'url')
+ self.assertEqual(collist, columns)
+ datalist = (
+ True,
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ identity_fakes.endpoint_url,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_endpoint_create_region(self):
+ arglist = [
+ identity_fakes.service_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ '--region', identity_fakes.endpoint_region,
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('service', identity_fakes.service_id),
+ ('interface', identity_fakes.endpoint_interface),
+ ('url', identity_fakes.endpoint_url),
+ ('region', identity_fakes.endpoint_region),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'service': identity_fakes.service_id,
+ 'url': identity_fakes.endpoint_url,
+ 'interface': identity_fakes.endpoint_interface,
+ 'enabled': True,
+ 'region': identity_fakes.endpoint_region,
+ }
+
+ self.endpoints_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('enabled', 'id', 'interface', 'region', 'service_id',
+ 'service_name', 'service_type', 'url')
+ self.assertEqual(collist, columns)
+ datalist = (
+ True,
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ identity_fakes.endpoint_url,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_endpoint_create_enable(self):
+ arglist = [
+ identity_fakes.service_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ '--enable'
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('service', identity_fakes.service_id),
+ ('interface', identity_fakes.endpoint_interface),
+ ('url', identity_fakes.endpoint_url),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'service': identity_fakes.service_id,
+ 'url': identity_fakes.endpoint_url,
+ 'interface': identity_fakes.endpoint_interface,
+ 'enabled': True,
+ 'region': None,
+ }
+
+ self.endpoints_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('enabled', 'id', 'interface', 'region', 'service_id',
+ 'service_name', 'service_type', 'url')
+ self.assertEqual(collist, columns)
+ datalist = (
+ True,
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ identity_fakes.endpoint_url,
+ )
+ self.assertEqual(datalist, data)
+
+ def test_endpoint_create_disable(self):
+ arglist = [
+ identity_fakes.service_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ '--disable',
+ ]
+ verifylist = [
+ ('enabled', False),
+ ('service', identity_fakes.service_id),
+ ('interface', identity_fakes.endpoint_interface),
+ ('url', identity_fakes.endpoint_url),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'service': identity_fakes.service_id,
+ 'url': identity_fakes.endpoint_url,
+ 'interface': identity_fakes.endpoint_interface,
+ 'enabled': False,
+ 'region': None,
+ }
+
+ self.endpoints_mock.create.assert_called_with(
+ **kwargs
+ )
+
+ collist = ('enabled', 'id', 'interface', 'region', 'service_id',
+ 'service_name', 'service_type', 'url')
+ self.assertEqual(collist, columns)
+ datalist = (
+ True,
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ identity_fakes.endpoint_url,
+ )
+ self.assertEqual(datalist, data)
+
+
+class TestEndpointDelete(TestEndpoint):
+
+ def setUp(self):
+ super(TestEndpointDelete, self).setUp()
+
+ # This is the return value for utils.find_resource(endpoint)
+ self.endpoints_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+ self.endpoints_mock.delete.return_value = None
+
+ # Get the command object to test
+ self.cmd = endpoint.DeleteEndpoint(self.app, None)
+
+ def test_endpoint_delete(self):
+ arglist = [
+ identity_fakes.endpoint_id,
+ ]
+ verifylist = [
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ self.endpoints_mock.delete.assert_called_with(
+ identity_fakes.endpoint_id,
+ )
+
+
+class TestEndpointList(TestEndpoint):
+
+ def setUp(self):
+ super(TestEndpointList, self).setUp()
+
+ self.endpoints_mock.list.return_value = [
+ fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ ),
+ ]
+
+ # This is the return value for common.find_resource(service)
+ self.services_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.SERVICE),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = endpoint.ListEndpoint(self.app, None)
+
+ def test_endpoint_list_no_options(self):
+ arglist = []
+ verifylist = []
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+ self.endpoints_mock.list.assert_called_with()
+
+ collist = ('ID', 'Region', 'Service Name', 'Service Type',
+ 'Enabled', 'Interface', 'URL')
+ self.assertEqual(collist, columns)
+ datalist = ((
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ True,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ ),)
+ self.assertEqual(datalist, tuple(data))
+
+ def test_endpoint_list_service(self):
+ arglist = [
+ '--service', identity_fakes.service_name,
+ ]
+ verifylist = [
+ ('service', identity_fakes.service_name),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'service': identity_fakes.service_id,
+ }
+ self.endpoints_mock.list.assert_called_with(**kwargs)
+
+ collist = ('ID', 'Region', 'Service Name', 'Service Type',
+ 'Enabled', 'Interface', 'URL')
+ self.assertEqual(collist, columns)
+ datalist = ((
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ True,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ ),)
+ self.assertEqual(datalist, tuple(data))
+
+ def test_endpoint_list_interface(self):
+ arglist = [
+ '--interface', identity_fakes.endpoint_interface,
+ ]
+ verifylist = [
+ ('interface', identity_fakes.endpoint_interface),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'interface': identity_fakes.endpoint_interface,
+ }
+ self.endpoints_mock.list.assert_called_with(**kwargs)
+
+ collist = ('ID', 'Region', 'Service Name', 'Service Type',
+ 'Enabled', 'Interface', 'URL')
+ self.assertEqual(collist, columns)
+ datalist = ((
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ True,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ ),)
+ self.assertEqual(datalist, tuple(data))
+
+ def test_endpoint_list_region(self):
+ arglist = [
+ '--region', identity_fakes.endpoint_region,
+ ]
+ verifylist = [
+ ('region', identity_fakes.endpoint_region),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # Set expected values
+ kwargs = {
+ 'region': identity_fakes.endpoint_region,
+ }
+ self.endpoints_mock.list.assert_called_with(**kwargs)
+
+ collist = ('ID', 'Region', 'Service Name', 'Service Type',
+ 'Enabled', 'Interface', 'URL')
+ self.assertEqual(collist, columns)
+ datalist = ((
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ True,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_url,
+ ),)
+ self.assertEqual(datalist, tuple(data))
+
+
+class TestEndpointSet(TestEndpoint):
+
+ def setUp(self):
+ super(TestEndpointSet, self).setUp()
+
+ # This is the return value for utils.find_resource(endpoint)
+ self.endpoints_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+
+ self.endpoints_mock.update.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+
+ # This is the return value for common.find_resource(service)
+ self.services_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.SERVICE),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = endpoint.SetEndpoint(self.app, None)
+
+ def test_endpoint_set_no_options(self):
+ arglist = [
+ identity_fakes.endpoint_id,
+ ]
+ verifylist = [
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ self.assertNotCalled(self.endpoints_mock.update)
+
+ def test_endpoint_set_interface(self):
+ arglist = [
+ '--interface', 'public',
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('interface', 'public'),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': None,
+ 'interface': 'public',
+ 'url': None,
+ 'region': None,
+ 'service': None,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+ def test_endpoint_set_url(self):
+ arglist = [
+ '--url', 'http://localhost:5000',
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('url', 'http://localhost:5000'),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': None,
+ 'interface': None,
+ 'url': 'http://localhost:5000',
+ 'region': None,
+ 'service': None,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+ def test_endpoint_set_service(self):
+ arglist = [
+ '--service', identity_fakes.service_id,
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('service', identity_fakes.service_id),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': None,
+ 'interface': None,
+ 'url': None,
+ 'region': None,
+ 'service': identity_fakes.service_id,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+ def test_endpoint_set_region(self):
+ arglist = [
+ '--region', 'e-rzzz',
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('region', 'e-rzzz'),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': None,
+ 'interface': None,
+ 'url': None,
+ 'region': 'e-rzzz',
+ 'service': None,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+ def test_endpoint_set_enable(self):
+ arglist = [
+ '--enable',
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('enabled', True),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': True,
+ 'interface': None,
+ 'url': None,
+ 'region': None,
+ 'service': None,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+ def test_endpoint_set_disable(self):
+ arglist = [
+ '--disable',
+ identity_fakes.endpoint_id
+ ]
+ verifylist = [
+ ('disabled', True),
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ result = self.cmd.run(parsed_args)
+ self.assertEqual(0, result)
+
+ # Set expected values
+ kwargs = {
+ 'enabled': False,
+ 'interface': None,
+ 'url': None,
+ 'region': None,
+ 'service': None,
+ }
+ self.endpoints_mock.update.assert_called_with(
+ identity_fakes.endpoint_id,
+ **kwargs
+ )
+
+
+class TestEndpointShow(TestEndpoint):
+
+ def setUp(self):
+ super(TestEndpointShow, self).setUp()
+
+ self.endpoints_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+
+ # This is the return value for common.find_resource(service)
+ self.services_mock.get.return_value = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.SERVICE),
+ loaded=True,
+ )
+
+ # Get the command object to test
+ self.cmd = endpoint.ShowEndpoint(self.app, None)
+
+ def test_endpoint_show(self):
+ arglist = [
+ identity_fakes.endpoint_id,
+ ]
+ verifylist = [
+ ('endpoint', identity_fakes.endpoint_id),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+ self.endpoints_mock.get.assert_called_with(
+ identity_fakes.endpoint_id,
+ )
+
+ collist = ('enabled', 'id', 'interface', 'region', 'service_id',
+ 'service_name', 'service_type', 'url')
+ self.assertEqual(collist, columns)
+ datalist = (
+ True,
+ identity_fakes.endpoint_id,
+ identity_fakes.endpoint_interface,
+ identity_fakes.endpoint_region,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ identity_fakes.endpoint_url,
+ )
+ self.assertEqual(datalist, data)