Add test list namespace function

Both test_images.py and test_images_member.py have test list funtion,
we can also add a function in test_images_metadefs_namespaces.py for
testing namespaces list.

Another reason is we have done create, get detail, update and delete
namespace test. But did not test the list.

Related link:
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html

Change-Id: I4caaccec9dea29f6a368f013a3edaad893fafada
This commit is contained in:
Li Wei 2016-09-23 17:20:06 +08:00 committed by liwei
parent 4f1ec14003
commit d004afa590
2 changed files with 16 additions and 0 deletions

View File

@ -40,6 +40,10 @@ class MetadataNamespacesTest(base.BaseV2ImageTest):
protected=True)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self._cleanup_namespace, namespace_name)
# list namespaces
bodys = self.namespaces_client.list_namespaces()['namespaces']
body = [namespace['namespace'] for namespace in bodys]
self.assertIn(namespace_name, body)
# get namespace details
body = self.namespaces_client.show_namespace(namespace_name)
self.assertEqual(namespace_name, body['namespace'])

View File

@ -34,6 +34,18 @@ class NamespacesClient(rest_client.RestClient):
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
def list_namespaces(self):
"""List namespaces
Available params: see http://developer.openstack.org/
api-ref/image/v2/metadefs-index.html#list-namespaces
"""
url = 'metadefs/namespaces'
resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
def show_namespace(self, namespace):
"""Show namespace details.