summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/compute
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2020-11-18 15:55:44 +0000
committerStephen Finucane <sfinucan@redhat.com>2021-01-08 12:14:43 +0000
commitfc24142ed41e15622687558c68d670bdc37223f0 (patch)
tree3a03305fa3dd74fece5cc754f58e7b99bd4de6de /openstackclient/tests/unit/compute
parent8a0f3fc6a8b30328c575bb5c3fc21ddc4f500d9d (diff)
downloadpython-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.py68
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):