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
diff --git a/tempest/api/image/v2/test_images_metadefs_namespaces.py b/tempest/api/image/v2/test_images_metadefs_namespaces.py
index 6fced00..a80a0cf 100644
--- a/tempest/api/image/v2/test_images_metadefs_namespaces.py
+++ b/tempest/api/image/v2/test_images_metadefs_namespaces.py
@@ -40,6 +40,10 @@
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'])
diff --git a/tempest/lib/services/image/v2/namespaces_client.py b/tempest/lib/services/image/v2/namespaces_client.py
index c92ff3a..359ff1d 100644
--- a/tempest/lib/services/image/v2/namespaces_client.py
+++ b/tempest/lib/services/image/v2/namespaces_client.py
@@ -34,6 +34,18 @@
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.