Merge "Wrap group type and group spec with api_version"
This commit is contained in:
@@ -14,11 +14,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from cinderclient import api_versions
|
||||||
|
from cinderclient import exceptions as exc
|
||||||
from cinderclient.v3 import group_types
|
from cinderclient.v3 import group_types
|
||||||
from cinderclient.tests.unit import utils
|
from cinderclient.tests.unit import utils
|
||||||
from cinderclient.tests.unit.v3 import fakes
|
from cinderclient.tests.unit.v3 import fakes
|
||||||
|
|
||||||
cs = fakes.FakeClient()
|
cs = fakes.FakeClient(api_version=api_versions.APIVersion('3.11'))
|
||||||
|
|
||||||
|
|
||||||
class GroupTypesTest(utils.TestCase):
|
class GroupTypesTest(utils.TestCase):
|
||||||
@@ -30,6 +32,12 @@ class GroupTypesTest(utils.TestCase):
|
|||||||
for t in tl:
|
for t in tl:
|
||||||
self.assertIsInstance(t, group_types.GroupType)
|
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)
|
||||||
|
|
||||||
def test_list_group_types_not_public(self):
|
def test_list_group_types_not_public(self):
|
||||||
t1 = cs.group_types.list(is_public=None)
|
t1 = cs.group_types.list(is_public=None)
|
||||||
cs.assert_called('GET', '/group_types?is_public=None')
|
cs.assert_called('GET', '/group_types?is_public=None')
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
"""Group Type interface."""
|
"""Group Type interface."""
|
||||||
|
|
||||||
|
from cinderclient import api_versions
|
||||||
from cinderclient import base
|
from cinderclient import base
|
||||||
|
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
"""Manage :class:`GroupType` resources."""
|
"""Manage :class:`GroupType` resources."""
|
||||||
resource_class = GroupType
|
resource_class = GroupType
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def list(self, search_opts=None, is_public=None):
|
def list(self, search_opts=None, is_public=None):
|
||||||
"""Lists all group types.
|
"""Lists all group types.
|
||||||
|
|
||||||
@@ -84,6 +86,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
query_string = '?is_public=%s' % is_public
|
query_string = '?is_public=%s' % is_public
|
||||||
return self._list("/group_types%s" % (query_string), "group_types")
|
return self._list("/group_types%s" % (query_string), "group_types")
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def get(self, group_type):
|
def get(self, group_type):
|
||||||
"""Get a specific group type.
|
"""Get a specific group type.
|
||||||
|
|
||||||
@@ -93,6 +96,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
return self._get("/group_types/%s" % base.getid(group_type),
|
return self._get("/group_types/%s" % base.getid(group_type),
|
||||||
"group_type")
|
"group_type")
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def default(self):
|
def default(self):
|
||||||
"""Get the default group type.
|
"""Get the default group type.
|
||||||
|
|
||||||
@@ -100,6 +104,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
"""
|
"""
|
||||||
return self._get("/group_types/default", "group_type")
|
return self._get("/group_types/default", "group_type")
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def delete(self, group_type):
|
def delete(self, group_type):
|
||||||
"""Deletes a specific group_type.
|
"""Deletes a specific group_type.
|
||||||
|
|
||||||
@@ -107,6 +112,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
"""
|
"""
|
||||||
return self._delete("/group_types/%s" % base.getid(group_type))
|
return self._delete("/group_types/%s" % base.getid(group_type))
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def create(self, name, description=None, is_public=True):
|
def create(self, name, description=None, is_public=True):
|
||||||
"""Creates a group type.
|
"""Creates a group type.
|
||||||
|
|
||||||
@@ -126,6 +132,7 @@ class GroupTypeManager(base.ManagerWithFind):
|
|||||||
|
|
||||||
return self._create("/group_types", body, "group_type")
|
return self._create("/group_types", body, "group_type")
|
||||||
|
|
||||||
|
@api_versions.wraps("3.11")
|
||||||
def update(self, group_type, name=None, description=None, is_public=None):
|
def update(self, group_type, name=None, description=None, is_public=None):
|
||||||
"""Update the name and/or description for a group type.
|
"""Update the name and/or description for a group type.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user