summaryrefslogtreecommitdiff
path: root/openstackclient/tests/identity
diff options
context:
space:
mode:
authorlin-hua-cheng <os.lcheng@gmail.com>2014-12-19 18:40:40 -0800
committerlin-hua-cheng <os.lcheng@gmail.com>2014-12-30 17:31:29 -0800
commit4a07e63e7ea4b99b10e4a3fd9ed06c0cf6ee905f (patch)
tree24c6dd6935a88f58ecdf6706d08943a41b590f0e /openstackclient/tests/identity
parent3541b0a695af12e31ecae4b4bedbe4235b5c13b4 (diff)
downloadpython-openstackclient-4a07e63e7ea4b99b10e4a3fd9ed06c0cf6ee905f.tar.gz
type should be required for v2.0 service create
Updated the service name to be optional, mostly matching the cli arguments with v3 service create. Implemented the following changes on service create: - if only a single positional is present, it's a <type>. This is not currently legal so it is considered a new case. - if --type option is present the positional is handled as <name>; display deprecation message - if --name option is present the positional is handled as <type>. Making --type optional is new, but back-compatible - Made --name and --type mutually exclusive. - only '--name <service-name> <type>' shall appear in the help output Change-Id: I8fd4adba3d8cd00d5a8cacc2c494d99d492c45a3 Closes-Bug: #1404073
Diffstat (limited to 'openstackclient/tests/identity')
-rw-r--r--openstackclient/tests/identity/v2_0/test_service.py75
1 files changed, 71 insertions, 4 deletions
diff --git a/openstackclient/tests/identity/v2_0/test_service.py b/openstackclient/tests/identity/v2_0/test_service.py
index 6c93574b..a0adea4e 100644
--- a/openstackclient/tests/identity/v2_0/test_service.py
+++ b/openstackclient/tests/identity/v2_0/test_service.py
@@ -44,14 +44,80 @@ class TestServiceCreate(TestService):
# Get the command object to test
self.cmd = service.CreateService(self.app, None)
- def test_service_create_name_type(self):
+ def test_service_create_with_type_positional(self):
+ arglist = [
+ identity_fakes.service_type,
+ ]
+ verifylist = [
+ ('type_or_name', identity_fakes.service_type),
+ ('type', None),
+ ('description', None),
+ ('name', None),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # ServiceManager.create(name, service_type, description)
+ self.services_mock.create.assert_called_with(
+ None,
+ identity_fakes.service_type,
+ None,
+ )
+
+ collist = ('description', 'id', 'name', 'type')
+ self.assertEqual(columns, collist)
+ datalist = (
+ identity_fakes.service_description,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ )
+ self.assertEqual(data, datalist)
+
+ def test_service_create_with_type_option(self):
arglist = [
'--type', identity_fakes.service_type,
identity_fakes.service_name,
]
verifylist = [
+ ('type_or_name', identity_fakes.service_name),
('type', identity_fakes.service_type),
('description', None),
+ ('name', None),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ # DisplayCommandBase.take_action() returns two tuples
+ columns, data = self.cmd.take_action(parsed_args)
+
+ # ServiceManager.create(name, service_type, description)
+ self.services_mock.create.assert_called_with(
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ None,
+ )
+
+ collist = ('description', 'id', 'name', 'type')
+ self.assertEqual(columns, collist)
+ datalist = (
+ identity_fakes.service_description,
+ identity_fakes.service_id,
+ identity_fakes.service_name,
+ identity_fakes.service_type,
+ )
+ self.assertEqual(data, datalist)
+
+ def test_service_create_with_name_option(self):
+ arglist = [
+ '--name', identity_fakes.service_name,
+ identity_fakes.service_type,
+ ]
+ verifylist = [
+ ('type_or_name', identity_fakes.service_type),
+ ('type', None),
+ ('description', None),
('name', identity_fakes.service_name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -78,12 +144,13 @@ class TestServiceCreate(TestService):
def test_service_create_description(self):
arglist = [
- '--type', identity_fakes.service_type,
+ '--name', identity_fakes.service_name,
'--description', identity_fakes.service_description,
- identity_fakes.service_name,
+ identity_fakes.service_type,
]
verifylist = [
- ('type', identity_fakes.service_type),
+ ('type_or_name', identity_fakes.service_type),
+ ('type', None),
('description', identity_fakes.service_description),
('name', identity_fakes.service_name),
]