Merge "Merge list_flavors_with_detail to list_flavors"
diff --git a/tempest/api/compute/admin/test_flavors.py b/tempest/api/compute/admin/test_flavors.py
index f12784e..d4b8311 100644
--- a/tempest/api/compute/admin/test_flavors.py
+++ b/tempest/api/compute/admin/test_flavors.py
@@ -125,7 +125,7 @@
         self.addCleanup(self.flavor_clean_up, flavor['id'])
         flag = False
         # Verify flavor is retrieved
-        flavors = self.client.list_flavors_with_detail()
+        flavors = self.client.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['name'] == flavor_name:
                 flag = True
@@ -165,7 +165,7 @@
         verify_flavor_response_extension(flavor)
 
         # Check if flavor is present in list
-        flavors = self.user_client.list_flavors_with_detail()
+        flavors = self.user_client.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['name'] == flavor_name:
                 verify_flavor_response_extension(flavor)
@@ -190,7 +190,7 @@
         self.addCleanup(self.flavor_clean_up, flavor['id'])
         # Verify flavor is retrieved
         flag = False
-        flavors = self.client.list_flavors_with_detail()
+        flavors = self.client.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['name'] == flavor_name:
                 flag = True
@@ -198,7 +198,7 @@
 
         # Verify flavor is not retrieved with other user
         flag = False
-        flavors = self.user_client.list_flavors_with_detail()
+        flavors = self.user_client.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['name'] == flavor_name:
                 flag = True
@@ -240,7 +240,7 @@
         flag = False
         self.new_client = self.flavors_client
         # Verify flavor is retrieved with new user
-        flavors = self.new_client.list_flavors_with_detail()
+        flavors = self.new_client.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['name'] == flavor_name:
                 flag = True
@@ -278,7 +278,7 @@
         def _test_string_variations(variations, flavor_name):
             for string in variations:
                 params = {'is_public': string}
-                flavors = self.client.list_flavors_with_detail(params)
+                flavors = self.client.list_flavors(detail=True, **params)
                 flavor = _flavor_lookup(flavors, flavor_name)
                 self.assertIsNotNone(flavor)
 
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 61d3dc6..4c743dc 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -87,7 +87,7 @@
         self.assertIn(resp_body, add_body)
 
         # The flavor is present in list.
-        flavors = self.flavors_client.list_flavors_with_detail()
+        flavors = self.flavors_client.list_flavors(detail=True)
         self.assertIn(new_flavor['id'], map(lambda x: x['id'], flavors))
 
         # Remove flavor access from a tenant.
@@ -96,5 +96,5 @@
         self.assertNotIn(resp_body, remove_body)
 
         # The flavor is not present in list.
-        flavors = self.flavors_client.list_flavors_with_detail()
+        flavors = self.flavors_client.list_flavors(detail=True)
         self.assertNotIn(new_flavor['id'], map(lambda x: x['id'], flavors))
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index 251f4ec..728fefb 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -41,7 +41,7 @@
     @test.idempotent_id('6e85fde4-b3cd-4137-ab72-ed5f418e8c24')
     def test_list_flavors_with_detail(self):
         # Detailed list of all flavors should contain the expected flavor
-        flavors = self.client.list_flavors_with_detail()
+        flavors = self.client.list_flavors(detail=True)
         flavor = self.client.show_flavor(self.flavor_ref)
         self.assertIn(flavor, flavors)
 
@@ -56,14 +56,14 @@
     def test_list_flavors_limit_results(self):
         # Only the expected number of flavors should be returned
         params = {'limit': 1}
-        flavors = self.client.list_flavors(params)
+        flavors = self.client.list_flavors(**params)
         self.assertEqual(1, len(flavors))
 
     @test.idempotent_id('b26f6327-2886-467a-82be-cef7a27709cb')
     def test_list_flavors_detailed_limit_results(self):
         # Only the expected number of flavors (detailed) should be returned
         params = {'limit': 1}
-        flavors = self.client.list_flavors_with_detail(params)
+        flavors = self.client.list_flavors(detail=True, **params)
         self.assertEqual(1, len(flavors))
 
     @test.idempotent_id('e800f879-9828-4bd0-8eae-4f17189951fb')
@@ -73,7 +73,7 @@
         flavor_id = flavor['id']
 
         params = {'marker': flavor_id}
-        flavors = self.client.list_flavors(params)
+        flavors = self.client.list_flavors(**params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
                          'The list of flavors did not start after the marker.')
 
@@ -84,7 +84,7 @@
         flavor_id = flavor['id']
 
         params = {'marker': flavor_id}
-        flavors = self.client.list_flavors_with_detail(params)
+        flavors = self.client.list_flavors(detail=True, **params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
                          'The list of flavors did not start after the marker.')
 
@@ -95,7 +95,7 @@
         flavor_id = flavor['id']
 
         params = {self._min_disk: flavor['disk'] + 1}
-        flavors = self.client.list_flavors_with_detail(params)
+        flavors = self.client.list_flavors(detail=True, **params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
 
     @test.idempotent_id('09fe7509-b4ee-4b34-bf8b-39532dc47292')
@@ -105,7 +105,7 @@
         flavor_id = flavor['id']
 
         params = {self._min_ram: flavor['ram'] + 1}
-        flavors = self.client.list_flavors_with_detail(params)
+        flavors = self.client.list_flavors(detail=True, **params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
 
     @test.idempotent_id('10645a4d-96f5-443f-831b-730711e11dd4')
@@ -115,7 +115,7 @@
         flavor_id = flavor['id']
 
         params = {self._min_disk: flavor['disk'] + 1}
-        flavors = self.client.list_flavors(params)
+        flavors = self.client.list_flavors(**params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
 
     @test.idempotent_id('935cf550-e7c8-4da6-8002-00f92d5edfaa')
@@ -125,5 +125,5 @@
         flavor_id = flavor['id']
 
         params = {self._min_ram: flavor['ram'] + 1}
-        flavors = self.client.list_flavors(params)
+        flavors = self.client.list_flavors(**params)
         self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
diff --git a/tempest/api/database/flavors/test_flavors.py b/tempest/api/database/flavors/test_flavors.py
index eeb472c..e698baa 100644
--- a/tempest/api/database/flavors/test_flavors.py
+++ b/tempest/api/database/flavors/test_flavors.py
@@ -58,7 +58,7 @@
     @test.services('compute')
     def test_compare_db_flavors_with_os(self):
         db_flavors = self.client.list_db_flavors()
-        os_flavors = self.os_flavors_client.list_flavors_with_detail()
+        os_flavors = self.os_flavors_client.list_flavors(detail=True)
         self.assertEqual(len(os_flavors), len(db_flavors),
                          "OS flavors %s do not match DB flavors %s" %
                          (os_flavors, db_flavors))
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index dee56ac..ebe4117 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -27,24 +27,19 @@
 
 class FlavorsClientJSON(service_client.ServiceClient):
 
-    def list_flavors(self, params=None):
+    def list_flavors(self, detail=False, **params):
         url = 'flavors'
+        _schema = schema.list_flavors
+
+        if detail:
+            url += '/detail'
+            _schema = schema.list_flavors_details
         if params:
             url += '?%s' % urllib.urlencode(params)
 
         resp, body = self.get(url)
         body = json.loads(body)
-        self.validate_response(schema.list_flavors, resp, body)
-        return service_client.ResponseBodyList(resp, body['flavors'])
-
-    def list_flavors_with_detail(self, params=None):
-        url = 'flavors/detail'
-        if params:
-            url += '?%s' % urllib.urlencode(params)
-
-        resp, body = self.get(url)
-        body = json.loads(body)
-        self.validate_response(schema.list_flavors_details, resp, body)
+        self.validate_response(_schema, resp, body)
         return service_client.ResponseBodyList(resp, body['flavors'])
 
     def show_flavor(self, flavor_id):
@@ -87,7 +82,7 @@
         # Did not use show_flavor(id) for verification as it gives
         # 200 ok even for deleted id. LP #981263
         # we can remove the loop here and use get by ID when bug gets sortedout
-        flavors = self.list_flavors_with_detail()
+        flavors = self.list_flavors(detail=True)
         for flavor in flavors:
             if flavor['id'] == id:
                 return False