image(s) schema image metadata API test

This patch is added to test get_images_schema and get_image_schema
image metadata APIs.
In addition to this, it changes the client function written for
these APIs.
A single method is written to merge all the schema client methods,
thus giving better way to code utilization.

Change-Id: I0fbd557e7abb7227b94488b270760858e0f32ca4
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 759c4a9..d448c01 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -249,3 +249,19 @@
 
         self.assertEqual(len(images_list), params['limit'],
                          "Failed to get images by limit")
+
+    @attr(type='gate')
+    def test_get_image_schema(self):
+        # Test to get image schema
+        schema = "image"
+        resp, body = self.client.get_schema(schema)
+        self.assertEqual(200, resp.status)
+        self.assertEqual("image", body['name'])
+
+    @attr(type='gate')
+    def test_get_images_schema(self):
+        # Test to get images schema
+        schema = "images"
+        resp, body = self.client.get_schema(schema)
+        self.assertEqual(200, resp.status)
+        self.assertEqual("images", body['name'])
diff --git a/tempest/services/image/v2/json/image_client.py b/tempest/services/image/v2/json/image_client.py
index 30c6ffc..b3014fc 100644
--- a/tempest/services/image/v2/json/image_client.py
+++ b/tempest/services/image/v2/json/image_client.py
@@ -39,23 +39,9 @@
                                       filters=self.filters,
                                       insecure=dscv)
 
-    def get_images_schema(self):
-        url = 'v2/schemas/images'
-        resp, body = self.get(url)
-        body = json.loads(body)
-        return resp, body
-
-    def get_image_schema(self):
-        url = 'v2/schemas/image'
-        resp, body = self.get(url)
-        body = json.loads(body)
-        return resp, body
-
     def _validate_schema(self, body, type='image'):
-        if type == 'image':
-            resp, schema = self.get_image_schema()
-        elif type == 'images':
-            resp, schema = self.get_images_schema()
+        if type in ['image', 'images']:
+            resp, schema = self.get_schema(type)
         else:
             raise ValueError("%s is not a valid schema type" % type)
 
@@ -184,3 +170,9 @@
         resp, _ = self.delete(url)
         self.expected_success(204, resp)
         return resp
+
+    def get_schema(self, schema):
+        url = 'v2/schemas/%s' % schema
+        resp, body = self.get(url)
+        body = json.loads(body)
+        return resp, body