Wrap GroupType class's function with api_version
GroupType class's functions only support 3.11 microversion or higher. So it should be wrapped like like one[1], otherwise these fuctions may be exposed to lib users with old microversion. [1]: https://github.com/openstack/python-cinderclient/blob/master/cinderclient/v3/services.py#L82 Closes-bug: #1619105 Change-Id: I08563898cb1a1eb212973e88a87ed1248f43fa77
This commit is contained in:
@@ -21,6 +21,7 @@ from cinderclient.tests.unit import utils
|
||||
from cinderclient.tests.unit.v3 import fakes
|
||||
|
||||
cs = fakes.FakeClient(api_version=api_versions.APIVersion('3.11'))
|
||||
pre_cs = fakes.FakeClient(api_version=api_versions.APIVersion('3.10'))
|
||||
|
||||
|
||||
class GroupTypesTest(utils.TestCase):
|
||||
@@ -33,8 +34,6 @@ class GroupTypesTest(utils.TestCase):
|
||||
self.assertIsInstance(t, group_types.GroupType)
|
||||
|
||||
def test_list_group_types_pre_version(self):
|
||||
pre_cs = fakes.FakeClient(api_version=
|
||||
api_versions.APIVersion('3.10'))
|
||||
self.assertRaises(exc.VersionNotFoundForAPIMethod,
|
||||
pre_cs.group_types.list)
|
||||
|
||||
@@ -95,6 +94,11 @@ class GroupTypesTest(utils.TestCase):
|
||||
{'group_specs': {'k': 'v'}})
|
||||
self._assert_request_id(res)
|
||||
|
||||
def test_set_key_pre_version(self):
|
||||
t = group_types.GroupType(pre_cs, {'id': 1})
|
||||
self.assertRaises(exc.VersionNotFoundForAPIMethod,
|
||||
t.set_keys, {'k': 'v'})
|
||||
|
||||
def test_unset_keys(self):
|
||||
t = cs.group_types.get(1)
|
||||
res = t.unset_keys(['k'])
|
||||
|
||||
@@ -33,6 +33,7 @@ class GroupType(base.Resource):
|
||||
return self._info.get("is_public",
|
||||
self._info.get("is_public", 'N/A'))
|
||||
|
||||
@api_versions.wraps("3.11")
|
||||
def get_keys(self):
|
||||
"""Get group specs from a group type.
|
||||
|
||||
@@ -43,6 +44,7 @@ class GroupType(base.Resource):
|
||||
base.getid(self))
|
||||
return body["group_specs"]
|
||||
|
||||
@api_versions.wraps("3.11")
|
||||
def set_keys(self, metadata):
|
||||
"""Set group specs on a group type.
|
||||
|
||||
@@ -56,6 +58,7 @@ class GroupType(base.Resource):
|
||||
"group_specs",
|
||||
return_raw=True)
|
||||
|
||||
@api_versions.wraps("3.11")
|
||||
def unset_keys(self, keys):
|
||||
"""Unset specs on a group type.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user