Merge "Remove code that supports older version falcon"
This commit is contained in:
commit
e4e7f01e6f
|
@ -16,20 +16,14 @@ limitations under the License.
|
|||
"""
|
||||
import sys
|
||||
|
||||
import falcon
|
||||
from oslo_config import cfg
|
||||
from paste import deploy
|
||||
from paste import urlmap
|
||||
import pkg_resources
|
||||
|
||||
from freezer_api.cmd import api
|
||||
from freezer_api.common import config
|
||||
|
||||
CONF = cfg.CONF
|
||||
# Define the minimum version of falcon at which we can use the "new" invocation
|
||||
# style for middleware (aka v1), i.e. the "middleware" named argument for
|
||||
# falcon.API.
|
||||
FALCON_MINVERSION_MIDDLEWARE = pkg_resources.parse_version('0.2.0b1')
|
||||
|
||||
|
||||
def root_app_factory(loader, global_conf, **local_conf):
|
||||
|
@ -47,16 +41,7 @@ def root_app_factory(loader, global_conf, **local_conf):
|
|||
|
||||
|
||||
def freezer_appv1_factory(global_conf, **local_conf):
|
||||
current_version = pkg_resources.parse_version(
|
||||
falcon.__version__ if hasattr(falcon,
|
||||
'__version__') else falcon.version)
|
||||
|
||||
# Check the currently installed version of falcon in order to invoke it
|
||||
# correctly.
|
||||
if current_version < FALCON_MINVERSION_MIDDLEWARE:
|
||||
return api.build_app_v0()
|
||||
else:
|
||||
return api.build_app_v1()
|
||||
return api.build_app_v1()
|
||||
|
||||
|
||||
def freezer_appv2_factory(global_conf, **local_conf):
|
||||
|
|
|
@ -30,38 +30,6 @@ class TestService(common.FreezerBaseTestCase):
|
|||
self.falcon_versions_middleware = ['0.2.0', '0.3.0', '1.0.0']
|
||||
super(TestService, self).setUp()
|
||||
|
||||
@patch('freezer_api.cmd.api.v1')
|
||||
@patch('freezer_api.cmd.api.manager')
|
||||
@patch('freezer_api.cmd.api.falcon')
|
||||
def test_on_old_falcon_builds_v0(self, mock_falcon, mock_driver, mock_v1):
|
||||
"""Test that falcon versions that should use old middleware syntax do so
|
||||
|
||||
:param mock_falcon: The falcon import freezer-api will try to
|
||||
start up
|
||||
:param mock_driver: Database driver
|
||||
:param mock_v1: List of endpoints for v1 for the freezer API.
|
||||
"""
|
||||
mock_driver.get_db.return_value = None
|
||||
mock_v1.endpoints = []
|
||||
|
||||
# Iterate through all of the versions of falcon that should be using
|
||||
# the old before=,after= invocation and ensure that freezer-api isn't
|
||||
# trying to invoke it in the old style.
|
||||
for version_string in self.falcon_versions_hooks:
|
||||
version_attribute = '__version__' if hasattr(
|
||||
falcon, '__version__') else 'version'
|
||||
with patch('falcon.' + version_attribute, version_string):
|
||||
# Attempt to invoke a mocked version of falcon to see what args
|
||||
# it was called with
|
||||
service.freezer_appv1_factory(None)
|
||||
|
||||
# Check kwargs to see if the correct arguments are being passed
|
||||
_, named_args = mock_falcon.API.call_args
|
||||
|
||||
self.assertIn('before', named_args)
|
||||
self.assertIn('after', named_args)
|
||||
self.assertNotIn('middleware', named_args)
|
||||
|
||||
@patch('freezer_api.cmd.api.v1')
|
||||
@patch('freezer_api.cmd.api.manager')
|
||||
@patch('freezer_api.cmd.api.falcon')
|
||||
|
|
Loading…
Reference in New Issue