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