add unittest for list namespaces interface

add unittest for list namespaces interface for Metadata

Change-Id: I447fc16a0854784a0ceff1a1ebfe1c277ec45f9b
diff --git a/tempest/tests/lib/services/image/v2/test_namespaces_client.py b/tempest/tests/lib/services/image/v2/test_namespaces_client.py
index 4cb9d01..3b057ad 100644
--- a/tempest/tests/lib/services/image/v2/test_namespaces_client.py
+++ b/tempest/tests/lib/services/image/v2/test_namespaces_client.py
@@ -26,6 +26,51 @@
         "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 @@
             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 @@
     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()