Ensure location header urls account for script_name
The API is at /v1... but if is mounted at /gnocchi/v1 then "/gnocchi" is the script_name and we need to account for that when generatin URLs for location headers. Pecan already does this where the application_url attribute is being used (for generating informational urls in response bodies). A new gabbi test suite is added which runs all of the existing gabbi tests with a prefix. Getting this to work identified a bug in gabbi, thus the update to test-requirements. Change-Id: I6e3b461610ad1b694e6ae3df33831b3f6224668f
This commit is contained in:
parent
7d5f2d66dc
commit
c9805eebb4
@ -111,6 +111,7 @@ def enforce(rule, target):
|
||||
|
||||
|
||||
def set_resp_location_hdr(location):
|
||||
location = '%s%s' % (pecan.request.script_name, location)
|
||||
# NOTE(sileht): according the pep-3333 the headers must be
|
||||
# str in py2 and py3 even this is not the same thing in both
|
||||
# version
|
||||
|
34
gnocchi/tests/gabbi/test_gabbi_prefix.py
Normal file
34
gnocchi/tests/gabbi/test_gabbi_prefix.py
Normal file
@ -0,0 +1,34 @@
|
||||
#
|
||||
# Copyright 2015 Red Hat. 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.
|
||||
|
||||
"""A test module to exercise the Gnocchi API with gabbi."""
|
||||
|
||||
import os
|
||||
|
||||
from gabbi import driver
|
||||
|
||||
from gnocchi.tests.gabbi import fixtures
|
||||
|
||||
|
||||
TESTS_DIR = 'gabbits'
|
||||
PREFIX = '/gnocchi'
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
"""Provide a TestSuite to the discovery process."""
|
||||
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
|
||||
return driver.build_tests(test_dir, loader, host=None, prefix=PREFIX,
|
||||
intercept=fixtures.setup_app,
|
||||
fixture_module=fixtures)
|
@ -1,5 +1,5 @@
|
||||
http://tarballs.openstack.org/ceilometer/ceilometer-master.tar.gz#egg=ceilometer
|
||||
gabbi>=0.6.0
|
||||
gabbi>=0.101.2
|
||||
fixtures
|
||||
keystonemiddleware>=1.5.0
|
||||
mock
|
||||
|
@ -1,5 +1,5 @@
|
||||
http://tarballs.openstack.org/ceilometer/ceilometer-master.tar.gz#egg=ceilometer
|
||||
gabbi>=0.100.1
|
||||
gabbi>=0.101.2
|
||||
coverage>=3.6
|
||||
fixtures
|
||||
keystonemiddleware>=1.5.0
|
||||
|
Loading…
Reference in New Issue
Block a user