Add unit tests for _get_unversioned_endpoint
This commit adds the first unit tests for the verify_tempest_config script which covers the code used to format an unversioned endpoint from a versioned one returned from the keystone catalog. This also breaks that section of the script off into a separate method so that mocks were not needed for such a simple test case. Partially implements bp: config-verification Change-Id: I6f48034af5fc187f6ae7d5c9b3dccb61f309ae25
This commit is contained in:
parent
f8b816af07
commit
9b89624925
|
@ -75,6 +75,12 @@ def verify_glance_api_versions(os, update):
|
|||
not CONF.image_feature_enabled.api_v2, update)
|
||||
|
||||
|
||||
def _get_unversioned_endpoint(base_url):
|
||||
endpoint_parts = urlparse.urlparse(base_url)
|
||||
endpoint = endpoint_parts.scheme + '://' + endpoint_parts.netloc
|
||||
return endpoint
|
||||
|
||||
|
||||
def _get_api_versions(os, service):
|
||||
client_dict = {
|
||||
'nova': os.servers_client,
|
||||
|
@ -82,8 +88,7 @@ def _get_api_versions(os, service):
|
|||
'cinder': os.volumes_client,
|
||||
}
|
||||
client_dict[service].skip_path()
|
||||
endpoint_parts = urlparse.urlparse(client_dict[service].base_url)
|
||||
endpoint = endpoint_parts.scheme + '://' + endpoint_parts.netloc
|
||||
endpoint = _get_unversioned_endpoint(client_dict[service].base_url)
|
||||
__, body = RAW_HTTP.request(endpoint, 'GET')
|
||||
client_dict[service].reset_path()
|
||||
body = json.loads(body)
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright 2014 IBM Corp.
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
from tempest.cmd import verify_tempest_config
|
||||
from tempest.tests import base
|
||||
|
||||
|
||||
class TestGetAPIVersions(base.TestCase):
|
||||
|
||||
def test_url_grab_versioned_nova_nossl(self):
|
||||
base_url = 'http://127.0.0.1:8774/v2/'
|
||||
endpoint = verify_tempest_config._get_unversioned_endpoint(base_url)
|
||||
self.assertEqual('http://127.0.0.1:8774', endpoint)
|
||||
|
||||
def test_url_grab_versioned_nova_ssl(self):
|
||||
base_url = 'https://127.0.0.1:8774/v3/'
|
||||
endpoint = verify_tempest_config._get_unversioned_endpoint(base_url)
|
||||
self.assertEqual('https://127.0.0.1:8774', endpoint)
|
Loading…
Reference in New Issue