summaryrefslogtreecommitdiff
path: root/openstackclient/tests
diff options
context:
space:
mode:
authorjiahui.qiang <jiahui.qiang@easystack.cn>2016-11-13 06:15:13 +0800
committerjiahui.qiang <jiahui.qiang@easystack.cn>2016-12-06 06:44:16 +0800
commitd083ddb12f4b8eb0d72bb4ff60113cd0904d8c1d (patch)
tree8e2c9ca0a74a65f52df26fcc41f6444a9aafc70d /openstackclient/tests
parent60370b46f5bbc9d3de7454f8efef4b5eae867a35 (diff)
downloadpython-openstackclient-d083ddb12f4b8eb0d72bb4ff60113cd0904d8c1d.tar.gz
Add --default option to "volume type list"
Add "--default" option to volume v2's "type list" command, it will show which volume type the volume service has set as default. Implements: bp cinder-command-support Change-Id: Iae7ebc633ebe5554cc88390a84361887ec211fb2
Diffstat (limited to 'openstackclient/tests')
-rw-r--r--openstackclient/tests/functional/volume/v2/test_volume_type.py5
-rw-r--r--openstackclient/tests/unit/volume/v2/test_type.py27
2 files changed, 31 insertions, 1 deletions
diff --git a/openstackclient/tests/functional/volume/v2/test_volume_type.py b/openstackclient/tests/functional/volume/v2/test_volume_type.py
index d8bd3a96..b4df5b2d 100644
--- a/openstackclient/tests/functional/volume/v2/test_volume_type.py
+++ b/openstackclient/tests/functional/volume/v2/test_volume_type.py
@@ -42,6 +42,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
raw_output = self.openstack('volume type list' + opts)
self.assertIn(self.NAME, raw_output)
+ def test_volume_type_list_default(self):
+ opts = self.get_opts(self.HEADERS)
+ raw_output = self.openstack('volume type list --default' + opts)
+ self.assertEqual("lvmdriver-1\n", raw_output)
+
def test_volume_type_show(self):
opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('volume type show ' + self.NAME + opts)
diff --git a/openstackclient/tests/unit/volume/v2/test_type.py b/openstackclient/tests/unit/volume/v2/test_type.py
index 325872d7..0d556e13 100644
--- a/openstackclient/tests/unit/volume/v2/test_type.py
+++ b/openstackclient/tests/unit/volume/v2/test_type.py
@@ -172,7 +172,11 @@ class TestTypeList(TestType):
"Description",
"Properties"
]
-
+ data_with_default_type = [(
+ volume_types[0].id,
+ volume_types[0].name,
+ True
+ )]
data = []
for t in volume_types:
data.append((
@@ -194,6 +198,7 @@ class TestTypeList(TestType):
super(TestTypeList, self).setUp()
self.types_mock.list.return_value = self.volume_types
+ self.types_mock.default.return_value = self.volume_types[0]
# get the command to test
self.cmd = volume_type.ListVolumeType(self.app, None)
@@ -203,6 +208,7 @@ class TestTypeList(TestType):
("long", False),
("private", False),
("public", False),
+ ("default", False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -220,6 +226,7 @@ class TestTypeList(TestType):
("long", True),
("private", False),
("public", True),
+ ("default", False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -236,6 +243,7 @@ class TestTypeList(TestType):
("long", False),
("private", True),
("public", False),
+ ("default", False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -244,6 +252,23 @@ class TestTypeList(TestType):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
+ def test_type_list_with_default_option(self):
+ arglist = [
+ "--default",
+ ]
+ verifylist = [
+ ("long", False),
+ ("private", False),
+ ("public", False),
+ ("default", True),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+ self.types_mock.default.assert_called_once_with()
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data_with_default_type, list(data))
+
class TestTypeSet(TestType):