From 6986a32e1cd6d0c0bdf973e5d4e4bcb3d1f45235 Mon Sep 17 00:00:00 2001 From: Huanxuan Ao Date: Fri, 12 Aug 2016 12:29:45 +0800 Subject: Add "--limit" and "--marker" options to "volume list" command Add ``--limit`` option to ``volume list`` command in volume v1, add ``--limit`` and ``--marker`` options to ``volume list`` command in volume v2. Change-Id: I327a252aa83ed84166da99cf6aa80334e0e6dd44 Partial-Bug: #1612484 --- .../tests/unit/volume/v1/test_volume.py | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'openstackclient/tests/unit/volume/v1') diff --git a/openstackclient/tests/unit/volume/v1/test_volume.py b/openstackclient/tests/unit/volume/v1/test_volume.py index f90566fd..38192849 100644 --- a/openstackclient/tests/unit/volume/v1/test_volume.py +++ b/openstackclient/tests/unit/volume/v1/test_volume.py @@ -13,6 +13,7 @@ # under the License. # +import argparse import copy import mock @@ -437,6 +438,7 @@ class TestVolumeList(TestVolume): ('all_projects', False), ('name', None), ('status', None), + ('limit', None), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -454,6 +456,7 @@ class TestVolumeList(TestVolume): ('all_projects', False), ('name', volume_fakes.volume_name), ('status', None), + ('limit', None), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -470,6 +473,7 @@ class TestVolumeList(TestVolume): ('all_projects', False), ('name', None), ('status', volume_fakes.volume_status), + ('limit', None), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -486,6 +490,7 @@ class TestVolumeList(TestVolume): ('all_projects', True), ('name', None), ('status', None), + ('limit', None), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -502,6 +507,7 @@ class TestVolumeList(TestVolume): ('all_projects', False), ('name', None), ('status', None), + ('limit', None), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -532,6 +538,41 @@ class TestVolumeList(TestVolume): ), ) self.assertEqual(datalist, tuple(data)) + def test_volume_list_with_limit(self): + arglist = [ + '--limit', '2', + ] + verifylist = [ + ('long', False), + ('all_projects', False), + ('name', None), + ('status', None), + ('limit', 2), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.volumes_mock.list.assert_called_once_with( + limit=2, + search_opts={ + 'status': None, + 'display_name': None, + 'all_tenants': False, } + ) + self.assertEqual(self.columns, columns) + self.assertEqual(self.datalist, tuple(data)) + + def test_volume_list_negative_limit(self): + arglist = [ + "--limit", "-2", + ] + verifylist = [ + ("limit", -2), + ] + self.assertRaises(argparse.ArgumentTypeError, self.check_parser, + self.cmd, arglist, verifylist) + class TestVolumeSet(TestVolume): -- cgit v1.2.1