summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-09-04 23:41:36 +0000
committerGerrit Code Review <review@openstack.org>2019-09-04 23:41:36 +0000
commit4bd9000eddfa559ab831df92b7108d15a4b15c87 (patch)
treec84fb51d0de203d2463992f40037830c4de10538 /cinderclient/tests/unit
parent6f761f6bf0764e4b42a56dbd73c24adf6be038e2 (diff)
parentd1b044b82a9d632e5769b377abe4f7f653cb94d4 (diff)
downloadpython-cinderclient-4bd9000eddfa559ab831df92b7108d15a4b15c87.tar.gz
Merge "Autonegotiate API version for shell"
Diffstat (limited to 'cinderclient/tests/unit')
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index cc3372c..f4aa598 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -46,6 +46,7 @@ import six
from six.moves.urllib import parse
import cinderclient
+from cinderclient import api_versions
from cinderclient import base
from cinderclient import client
from cinderclient import exceptions
@@ -92,7 +93,12 @@ class ShellTest(utils.TestCase):
self.cs = mock.Mock()
def run_command(self, cmd):
- self.shell.main(cmd.split())
+ # Ensure the version negotiation indicates that
+ # all versions are supported
+ with mock.patch('cinderclient.api_versions._get_server_version_range',
+ return_value=(api_versions.APIVersion('3.0'),
+ api_versions.APIVersion('3.99'))):
+ self.shell.main(cmd.split())
def assert_called(self, method, url, body=None,
partial_body=None, **kwargs):
@@ -295,6 +301,14 @@ class ShellTest(utils.TestCase):
mock_print.assert_called_once_with(mock.ANY, key_list,
exclude_unavailable=True, sortby_index=0)
+ @mock.patch("cinderclient.shell.OpenStackCinderShell.downgrade_warning")
+ def test_list_version_downgrade(self, mock_warning):
+ self.run_command('--os-volume-api-version 3.998 list')
+ mock_warning.assert_called_once_with(
+ api_versions.APIVersion('3.998'),
+ api_versions.APIVersion(api_versions.MAX_VERSION)
+ )
+
def test_list_availability_zone(self):
self.run_command('availability-zone-list')
self.assert_called('GET', '/os-availability-zone')