diff options
| author | Stephen Finucane <sfinucan@redhat.com> | 2020-11-18 15:55:44 +0000 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2021-01-08 12:14:43 +0000 |
| commit | fc24142ed41e15622687558c68d670bdc37223f0 (patch) | |
| tree | 3a03305fa3dd74fece5cc754f58e7b99bd4de6de /openstackclient/tests/unit/compute | |
| parent | 8a0f3fc6a8b30328c575bb5c3fc21ddc4f500d9d (diff) | |
| download | python-openstackclient-fc24142ed41e15622687558c68d670bdc37223f0.tar.gz | |
compute: Add missing options for 'keypair list'
Add pagination parameters, '--limit' and '--marker'. This isn't
compatible with our client-side '--project' parameter so we error out
for that.
Change-Id: I403cf0fb7aabad4a3dfda5adae62d47ecf7faf5c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/compute')
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/test_keypair.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/compute/v2/test_keypair.py b/openstackclient/tests/unit/compute/v2/test_keypair.py index 5a17808f..65d9396a 100644 --- a/openstackclient/tests/unit/compute/v2/test_keypair.py +++ b/openstackclient/tests/unit/compute/v2/test_keypair.py @@ -569,6 +569,74 @@ class TestKeypairList(TestKeypair): tests_utils.ParserException, self.check_parser, self.cmd, arglist, None) + @mock.patch.object( + sdk_utils, 'supports_microversion', new=mock.Mock(return_value=True)) + def test_keypair_list_with_limit(self): + arglist = [ + '--limit', '1', + ] + verifylist = [ + ('limit', 1), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.cmd.take_action(parsed_args) + + self.sdk_client.keypairs.assert_called_with(limit=1) + + @mock.patch.object( + sdk_utils, 'supports_microversion', new=mock.Mock(return_value=False)) + def test_keypair_list_with_limit_pre_v235(self): + arglist = [ + '--limit', '1', + ] + verifylist = [ + ('limit', 1), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + ex = self.assertRaises( + exceptions.CommandError, + self.cmd.take_action, + parsed_args) + + self.assertIn( + '--os-compute-api-version 2.35 or greater is required', str(ex)) + + @mock.patch.object( + sdk_utils, 'supports_microversion', new=mock.Mock(return_value=True)) + def test_keypair_list_with_marker(self): + arglist = [ + '--marker', 'test_kp', + ] + verifylist = [ + ('marker', 'test_kp'), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.cmd.take_action(parsed_args) + + self.sdk_client.keypairs.assert_called_with(marker='test_kp') + + @mock.patch.object( + sdk_utils, 'supports_microversion', new=mock.Mock(return_value=False)) + def test_keypair_list_with_marker_pre_v235(self): + arglist = [ + '--marker', 'test_kp', + ] + verifylist = [ + ('marker', 'test_kp'), + ] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + ex = self.assertRaises( + exceptions.CommandError, + self.cmd.take_action, + parsed_args) + + self.assertIn( + '--os-compute-api-version 2.35 or greater is required', str(ex)) + class TestKeypairShow(TestKeypair): |
