Make identity v2 service_client use **kwargs
As we discussed on
http://lists.openstack.org/pipermail/openstack-dev/2015-July/068864.html
All http POST/PUT methods need to contain **kwargs as their arguments.
This patch makes identity v2 service_client use **kwargs.
Partially implements blueprint consistent-service-method-names
Change-Id: Ib5677cc185ace03f2e8824ba84365476823f50d5
diff --git a/tempest/api/identity/admin/v2/test_endpoints.py b/tempest/api/identity/admin/v2/test_endpoints.py
index 4493c8e..651a316 100644
--- a/tempest/api/identity/admin/v2/test_endpoints.py
+++ b/tempest/api/identity/admin/v2/test_endpoints.py
@@ -28,7 +28,8 @@
s_type = data_utils.rand_name('type')
s_description = data_utils.rand_name('description')
cls.service_data = cls.services_client.create_service(
- s_name, s_type, description=s_description)['OS-KSADM:service']
+ name=s_name, type=s_type,
+ description=s_description)['OS-KSADM:service']
cls.service_id = cls.service_data['id']
cls.service_ids.append(cls.service_id)
# Create endpoints so as to use for LIST and GET test cases
diff --git a/tempest/api/identity/admin/v2/test_services.py b/tempest/api/identity/admin/v2/test_services.py
index fe83759..6c9b564 100644
--- a/tempest/api/identity/admin/v2/test_services.py
+++ b/tempest/api/identity/admin/v2/test_services.py
@@ -35,10 +35,11 @@
# GET Service
# Creating a Service
name = data_utils.rand_name('service')
- type = data_utils.rand_name('type')
+ s_type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
service_data = self.services_client.create_service(
- name, type, description=description)['OS-KSADM:service']
+ name=name, type=s_type,
+ description=description)['OS-KSADM:service']
self.assertFalse(service_data['id'] is None)
self.addCleanup(self._del_service, service_data['id'])
# Verifying response body of create service
@@ -46,7 +47,7 @@
self.assertIn('name', service_data)
self.assertEqual(name, service_data['name'])
self.assertIn('type', service_data)
- self.assertEqual(type, service_data['type'])
+ self.assertEqual(s_type, service_data['type'])
self.assertIn('description', service_data)
self.assertEqual(description, service_data['description'])
# Get service
@@ -68,15 +69,15 @@
def test_create_service_without_description(self):
# Create a service only with name and type
name = data_utils.rand_name('service')
- type = data_utils.rand_name('type')
- service = self.services_client.create_service(name,
- type)['OS-KSADM:service']
+ s_type = data_utils.rand_name('type')
+ service = self.services_client.create_service(
+ name=name, type=s_type)['OS-KSADM:service']
self.assertIn('id', service)
self.addCleanup(self._del_service, service['id'])
self.assertIn('name', service)
self.assertEqual(name, service['name'])
self.assertIn('type', service)
- self.assertEqual(type, service['type'])
+ self.assertEqual(s_type, service['type'])
@test.attr(type='smoke')
@test.idempotent_id('34ea6489-012d-4a86-9038-1287cadd5eca')
@@ -85,10 +86,12 @@
services = []
for _ in moves.xrange(3):
name = data_utils.rand_name('service')
- type = data_utils.rand_name('type')
+ s_type = data_utils.rand_name('type')
description = data_utils.rand_name('description')
+
service = self.services_client.create_service(
- name, type, description=description)['OS-KSADM:service']
+ name=name, type=s_type,
+ description=description)['OS-KSADM:service']
services.append(service)
service_ids = map(lambda x: x['id'], services)
diff --git a/tempest/services/identity/v2/json/services_client.py b/tempest/services/identity/v2/json/services_client.py
index d8be6c6..4a63d56 100644
--- a/tempest/services/identity/v2/json/services_client.py
+++ b/tempest/services/identity/v2/json/services_client.py
@@ -13,6 +13,7 @@
# limitations under the License.
from oslo_serialization import jsonutils as json
+from six.moves.urllib import parse as urllib
from tempest.lib.common import rest_client
@@ -20,14 +21,9 @@
class ServicesClient(rest_client.RestClient):
api_version = "v2.0"
- def create_service(self, name, type, **kwargs):
+ def create_service(self, **kwargs):
"""Create a service."""
- post_body = {
- 'name': name,
- 'type': type,
- 'description': kwargs.get('description')
- }
- post_body = json.dumps({'OS-KSADM:service': post_body})
+ post_body = json.dumps({'OS-KSADM:service': kwargs})
resp, body = self.post('/OS-KSADM/services', post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
@@ -41,9 +37,12 @@
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
- def list_services(self):
+ def list_services(self, **params):
"""List Service - Returns Services."""
- resp, body = self.get('/OS-KSADM/services')
+ url = '/OS-KSADM/services'
+ if params:
+ url += '?%s' % urllib.urlencode(params)
+ resp, body = self.get(url)
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)