add unittest for list namespaces interface

add unittest for list namespaces interface for Metadata

Change-Id: I447fc16a0854784a0ceff1a1ebfe1c277ec45f9b
This commit is contained in:
wangzhiguang 2019-12-16 14:39:03 +08:00
parent 9ef4316091
commit c9c9b476ee
1 changed files with 58 additions and 0 deletions

View File

@ -26,6 +26,51 @@ class TestNamespacesClient(base.BaseServiceTest):
"protected": True
}
FAKE_LIST_NAMESPACES = {
"first": "/v2/metadefs/namespaces?sort_key=created_at&sort_dir=asc",
"namespaces": [
{
"created_at": "2014-08-28T17:13:06Z",
"description": "OS::Compute::Libvirt",
"display_name": "libvirt Driver Options",
"namespace": "OS::Compute::Libvirt",
"owner": "admin",
"protected": True,
"resource_type_associations": [
{
"created_at": "2014-08-28T17:13:06Z",
"name": "OS::Glance::Image",
"updated_at": "2014-08-28T17:13:06Z"
}
],
"schema": "/v2/schemas/metadefs/namespace",
"self": "/v2/metadefs/namespaces/OS::Compute::Libvirt",
"updated_at": "2014-08-28T17:13:06Z",
"visibility": "public"
},
{
"created_at": "2014-08-28T17:13:06Z",
"description": "OS::Compute::Quota",
"display_name": "Flavor Quota",
"namespace": "OS::Compute::Quota",
"owner": "admin",
"protected": True,
"resource_type_associations": [
{
"created_at": "2014-08-28T17:13:06Z",
"name": "OS::Nova::Flavor",
"updated_at": "2014-08-28T17:13:06Z"
}
],
"schema": "/v2/schemas/metadefs/namespace",
"self": "/v2/metadefs/namespaces/OS::Compute::Quota",
"updated_at": "2014-08-28T17:13:06Z",
"visibility": "public"
}
],
"schema": "/v2/schemas/metadefs/namespaces"
}
FAKE_UPDATE_NAMESPACE = {
"namespace": "OS::Compute::Hypervisor",
"visibility": "public",
@ -48,6 +93,13 @@ class TestNamespacesClient(base.BaseServiceTest):
bytes_body,
namespace="OS::Compute::Hypervisor")
def _test_list_namespaces(self, bytes_body=False):
self.check_service_client_function(
self.client.list_namespaces,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_LIST_NAMESPACES,
bytes_body)
def _test_create_namespace(self, bytes_body=False):
self.check_service_client_function(
self.client.create_namespace,
@ -74,6 +126,12 @@ class TestNamespacesClient(base.BaseServiceTest):
def test_show_namespace_with_bytes_body(self):
self._test_show_namespace(bytes_body=True)
def test_list_namespaces_with_str_body(self):
self._test_list_namespaces()
def test_list_namespaces_with_bytes_body(self):
self._test_list_namespaces(bytes_body=True)
def test_create_namespace_with_str_body(self):
self._test_create_namespace()