Make network clients use rest_client
Now service_client is unnecessary because that is the same as
rest_client. This patch makes network clients use the rest_client,
and we will remove service_client for the cleanup in the future.
This patch removes these clients from a certain test because this
test is just for service_client, not rest_client as the test name.
We have added this test for verifying all arguments are passed into
rest_client via service_client. However, this patch some clients use
rest_client directly, so this test becomes meaningless for these
clients. That is a reason why the migrated clients(into tempest.lib
before) are not contained in this test.
Partially implements blueprint consistent-service-method-names
Change-Id: I1922d0937162827f5c720bf3d331f9c7695506d2
diff --git a/tempest/services/network/json/base.py b/tempest/services/network/json/base.py
index 6ebc245..a6ada04 100644
--- a/tempest/services/network/json/base.py
+++ b/tempest/services/network/json/base.py
@@ -13,10 +13,10 @@
from oslo_serialization import jsonutils as json
from six.moves.urllib import parse as urllib
-from tempest.common import service_client
+from tempest.lib.common import rest_client
-class BaseNetworkClient(service_client.ServiceClient):
+class BaseNetworkClient(rest_client.RestClient):
"""Base class for Tempest REST clients for Neutron.
@@ -34,13 +34,13 @@
resp, body = self.get(req_uri)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
+ return rest_client.ResponseBody(resp, body)
def delete_resource(self, uri):
req_uri = self.uri_prefix + uri
resp, body = self.delete(req_uri)
self.expected_success(204, resp.status)
- return service_client.ResponseBody(resp, body)
+ return rest_client.ResponseBody(resp, body)
def show_resource(self, uri, **fields):
# fields is a dict which key is 'fields' and value is a
@@ -52,7 +52,7 @@
resp, body = self.get(req_uri)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
+ return rest_client.ResponseBody(resp, body)
def create_resource(self, uri, post_data):
req_uri = self.uri_prefix + uri
@@ -60,7 +60,7 @@
resp, body = self.post(req_uri, req_post_data)
body = json.loads(body)
self.expected_success(201, resp.status)
- return service_client.ResponseBody(resp, body)
+ return rest_client.ResponseBody(resp, body)
def update_resource(self, uri, post_data):
req_uri = self.uri_prefix + uri
@@ -68,4 +68,4 @@
resp, body = self.put(req_uri, req_post_data)
body = json.loads(body)
self.expected_success(200, resp.status)
- return service_client.ResponseBody(resp, body)
+ return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
deleted file mode 100644
index 49857ae..0000000
--- a/tempest/tests/common/test_service_clients.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2015 NEC Corporation. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-import mock
-import random
-import six
-
-from tempest.services.network.json import network_client
-from tempest.tests import base
-
-
-class TestServiceClient(base.TestCase):
-
- @mock.patch('tempest.lib.common.rest_client.RestClient.__init__')
- def test_service_client_creations_with_specified_args(self, mock_init):
- test_clients = [
- network_client.NetworkClient,
- ]
-
- for client in test_clients:
- fake_string = six.text_type(random.randint(1, 0x7fffffff))
- auth = 'auth' + fake_string
- service = 'service' + fake_string
- region = 'region' + fake_string
- params = {
- 'endpoint_type': 'URL' + fake_string,
- 'build_interval': random.randint(1, 100),
- 'build_timeout': random.randint(1, 100),
- 'disable_ssl_certificate_validation':
- True if random.randint(0, 1) else False,
- 'ca_certs': None,
- 'trace_requests': 'foo' + fake_string
- }
- client(auth, service, region, **params)
- mock_init.assert_called_once_with(auth, service, region, **params)
- mock_init.reset_mock()