Merge "[V3] Make service_client use **kwargs"
This commit is contained in:
commit
aff96e20bf
@ -33,9 +33,9 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
s_name = data_utils.rand_name('service')
|
s_name = data_utils.rand_name('service')
|
||||||
s_type = data_utils.rand_name('type')
|
s_type = data_utils.rand_name('type')
|
||||||
s_description = data_utils.rand_name('description')
|
s_description = data_utils.rand_name('description')
|
||||||
cls.service_data =\
|
cls.service_data = (
|
||||||
cls.service_client.create_service(s_name, s_type,
|
cls.service_client.create_service(name=s_name, type=s_type,
|
||||||
description=s_description)
|
description=s_description))
|
||||||
cls.service_data = cls.service_data['service']
|
cls.service_data = cls.service_data['service']
|
||||||
cls.service_id = cls.service_data['id']
|
cls.service_id = cls.service_data['id']
|
||||||
cls.service_ids.append(cls.service_id)
|
cls.service_ids.append(cls.service_id)
|
||||||
@ -112,9 +112,9 @@ class EndPointsTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
s_name = data_utils.rand_name('service')
|
s_name = data_utils.rand_name('service')
|
||||||
s_type = data_utils.rand_name('type')
|
s_type = data_utils.rand_name('type')
|
||||||
s_description = data_utils.rand_name('description')
|
s_description = data_utils.rand_name('description')
|
||||||
service2 =\
|
service2 = (
|
||||||
self.service_client.create_service(s_name, s_type,
|
self.service_client.create_service(name=s_name, type=s_type,
|
||||||
description=s_description)
|
description=s_description))
|
||||||
service2 = service2['service']
|
service2 = service2['service']
|
||||||
self.service_ids.append(service2['id'])
|
self.service_ids.append(service2['id'])
|
||||||
# Updating endpoint with new values
|
# Updating endpoint with new values
|
||||||
|
@ -37,7 +37,7 @@ class EndpointsNegativeTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
s_type = data_utils.rand_name('type')
|
s_type = data_utils.rand_name('type')
|
||||||
s_description = data_utils.rand_name('description')
|
s_description = data_utils.rand_name('description')
|
||||||
cls.service_data = (
|
cls.service_data = (
|
||||||
cls.service_client.create_service(s_name, s_type,
|
cls.service_client.create_service(name=s_name, type=s_type,
|
||||||
description=s_description)
|
description=s_description)
|
||||||
['service'])
|
['service'])
|
||||||
cls.service_id = cls.service_data['id']
|
cls.service_id = cls.service_data['id']
|
||||||
|
@ -37,7 +37,7 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
serv_type = data_utils.rand_name('type')
|
serv_type = data_utils.rand_name('type')
|
||||||
desc = data_utils.rand_name('description')
|
desc = data_utils.rand_name('description')
|
||||||
create_service = self.service_client.create_service(
|
create_service = self.service_client.create_service(
|
||||||
serv_type, name=name, description=desc)['service']
|
type=serv_type, name=name, description=desc)['service']
|
||||||
self.addCleanup(self._del_service, create_service['id'])
|
self.addCleanup(self._del_service, create_service['id'])
|
||||||
self.assertIsNotNone(create_service['id'])
|
self.assertIsNotNone(create_service['id'])
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
name = data_utils.rand_name('service')
|
name = data_utils.rand_name('service')
|
||||||
serv_type = data_utils.rand_name('type')
|
serv_type = data_utils.rand_name('type')
|
||||||
service = self.service_client.create_service(
|
service = self.service_client.create_service(
|
||||||
serv_type, name=name)['service']
|
type=serv_type, name=name)['service']
|
||||||
self.addCleanup(self.service_client.delete_service, service['id'])
|
self.addCleanup(self.service_client.delete_service, service['id'])
|
||||||
self.assertIn('id', service)
|
self.assertIn('id', service)
|
||||||
expected_data = {'name': name, 'type': serv_type}
|
expected_data = {'name': name, 'type': serv_type}
|
||||||
@ -82,7 +82,7 @@ class ServicesTestJSON(base.BaseIdentityV3AdminTest):
|
|||||||
name = data_utils.rand_name('service')
|
name = data_utils.rand_name('service')
|
||||||
serv_type = data_utils.rand_name('type')
|
serv_type = data_utils.rand_name('type')
|
||||||
create_service = self.service_client.create_service(
|
create_service = self.service_client.create_service(
|
||||||
serv_type, name=name)['service']
|
type=serv_type, name=name)['service']
|
||||||
self.addCleanup(self.service_client.delete_service,
|
self.addCleanup(self.service_client.delete_service,
|
||||||
create_service['id'])
|
create_service['id'])
|
||||||
service_ids.append(create_service['id'])
|
service_ids.append(create_service['id'])
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
"""
|
||||||
|
http://developer.openstack.org/api-ref-identity-v3.html#service-catalog-v3
|
||||||
|
"""
|
||||||
|
|
||||||
from oslo_serialization import jsonutils as json
|
from oslo_serialization import jsonutils as json
|
||||||
|
|
||||||
from tempest.common import service_client
|
from tempest.common import service_client
|
||||||
@ -22,17 +26,12 @@ class ServiceClient(service_client.ServiceClient):
|
|||||||
api_version = "v3"
|
api_version = "v3"
|
||||||
|
|
||||||
def update_service(self, service_id, **kwargs):
|
def update_service(self, service_id, **kwargs):
|
||||||
"""Updates a service."""
|
"""Updates a service.
|
||||||
body = self.show_service(service_id)['service']
|
|
||||||
name = kwargs.get('name', body['name'])
|
Available params: see http://developer.openstack.org/
|
||||||
type = kwargs.get('type', body['type'])
|
api-ref-identity-v3.html#updateService
|
||||||
desc = kwargs.get('description', body['description'])
|
"""
|
||||||
patch_body = {
|
patch_body = json.dumps({'service': kwargs})
|
||||||
'description': desc,
|
|
||||||
'type': type,
|
|
||||||
'name': name
|
|
||||||
}
|
|
||||||
patch_body = json.dumps({'service': patch_body})
|
|
||||||
resp, body = self.patch('services/%s' % service_id, patch_body)
|
resp, body = self.patch('services/%s' % service_id, patch_body)
|
||||||
self.expected_success(200, resp.status)
|
self.expected_success(200, resp.status)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
@ -46,15 +45,13 @@ class ServiceClient(service_client.ServiceClient):
|
|||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
return service_client.ResponseBody(resp, body)
|
return service_client.ResponseBody(resp, body)
|
||||||
|
|
||||||
def create_service(self, serv_type, name=None, description=None,
|
def create_service(self, **kwargs):
|
||||||
enabled=True):
|
"""Creates a service.
|
||||||
body_dict = {
|
|
||||||
'name': name,
|
Available params: see http://developer.openstack.org/
|
||||||
'type': serv_type,
|
api-ref-identity-v3.html#createService
|
||||||
'enabled': enabled,
|
"""
|
||||||
'description': description,
|
body = json.dumps({'service': kwargs})
|
||||||
}
|
|
||||||
body = json.dumps({'service': body_dict})
|
|
||||||
resp, body = self.post("services", body)
|
resp, body = self.post("services", body)
|
||||||
self.expected_success(201, resp.status)
|
self.expected_success(201, resp.status)
|
||||||
body = json.loads(body)
|
body = json.loads(body)
|
||||||
|
Loading…
Reference in New Issue
Block a user