From d083ddb12f4b8eb0d72bb4ff60113cd0904d8c1d Mon Sep 17 00:00:00 2001 From: "jiahui.qiang" Date: Sun, 13 Nov 2016 06:15:13 +0800 Subject: 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 --- openstackclient/tests/unit/volume/v2/test_type.py | 27 ++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'openstackclient/tests/unit') 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): -- cgit v1.2.1