add show default group type details and unit test

add show default group type detail api to v3 group types client

Change-Id: I52e2382db7046f233ee03a1e3f79c6f2296cba85
This commit is contained in:
wangzhiguang 2019-07-13 16:40:46 +08:00
parent d605315e7f
commit 03c9c94c89
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Add show default group type details API to v3 group_types_client library.
* show_default_group_type

View File

@ -63,6 +63,18 @@ class GroupTypesClient(base_client.BaseClient):
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def show_default_group_type(self):
"""Returns the details of default group_type.
For more information, please refer to the official API reference:
https://developer.openstack.org/api-ref/block-storage/v3/#show-default-group-type-details
"""
url = 'group_types/default'
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def show_group_type(self, group_type_id):
"""Returns the details of a single group_type.

View File

@ -40,6 +40,16 @@ class TestGroupTypesClient(base.BaseServiceTest):
}
}
FAKE_INFO_DEFAULT_GROUP_TYPE = {
"group_type": {
"id": "7270c56e-6354-4528-8e8b-f54dee2232c8",
"name": "group-type-default",
"description": "default group type",
"is_public": True,
"group_specs": {},
}
}
FAKE_LIST_GROUP_TYPES = {
"group_types": [
{
@ -114,6 +124,13 @@ class TestGroupTypesClient(base.BaseServiceTest):
bytes_body,
group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5")
def _test_show_default_group_type(self, bytes_body=False):
self.check_service_client_function(
self.client.show_default_group_type,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_INFO_DEFAULT_GROUP_TYPE,
bytes_body)
def _test_list_group_types(self, bytes_body=False):
self.check_service_client_function(
self.client.list_group_types,
@ -192,6 +209,12 @@ class TestGroupTypesClient(base.BaseServiceTest):
def test_show_group_type_with_bytes_body(self):
self._test_show_group_type(bytes_body=True)
def test_show_default_group_type_with_str_body(self):
self._test_show_default_group_type()
def test_show_default_group_type_with_bytes_body(self):
self._test_show_default_group_type(bytes_body=True)
def test_list_group_types_with_str_body(self):
self._test_list_group_types()