summaryrefslogtreecommitdiff
path: root/oslo_middleware/tests
diff options
context:
space:
mode:
authorMehdi Abaakouk <sileht@redhat.com>2015-08-20 07:52:59 +0200
committerMehdi Abaakouk <sileht@redhat.com>2015-08-20 16:49:32 +0200
commitc78b156723cb4895be2ee0a55e4b9d9726b5b1c1 (patch)
tree2aaea2563439b7bd90010decc3fcbd7d468819f1 /oslo_middleware/tests
parenta5a0a2f7a7926da4fb9025123d99ff44fa1a6afe (diff)
downloadoslo-middleware-c78b156723cb4895be2ee0a55e4b9d9726b5b1c1.tar.gz
Restore backward compat of paste factory
Some application inherits from our middleware class When we homogenize the signature and configuration handling of all middlewares we break them. This change fixes that. Closes-bug: #1486735 Change-Id: I40c3d59110c6f8c5a1b3d3ccc734dc441069b025
Diffstat (limited to 'oslo_middleware/tests')
-rw-r--r--oslo_middleware/tests/test_base.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/oslo_middleware/tests/test_base.py b/oslo_middleware/tests/test_base.py
index 7124a49..ad48da5 100644
--- a/oslo_middleware/tests/test_base.py
+++ b/oslo_middleware/tests/test_base.py
@@ -14,28 +14,25 @@
import webob
+from oslo_middleware.base import ConfigurableMiddleware
from oslo_middleware.base import Middleware
from oslotest.base import BaseTestCase
+@webob.dec.wsgify
+def application(req):
+ return 'Hello, World!!!'
+
+
class TestBase(BaseTestCase):
"""Test the base middleware class."""
- def setUp(self):
- """Setup the tests."""
- super(BaseTestCase, self).setUp()
-
def test_extend_with_request(self):
"""Assert that a newer middleware behaves as appropriate.
This tests makes sure that the request is passed to the
middleware's implementation.
"""
- # Create an application.
- @webob.dec.wsgify
- def application(req):
- return 'Hello, World!!!'
-
# Bootstrap the application
self.application = RequestBase(application)
@@ -52,11 +49,6 @@ class TestBase(BaseTestCase):
middleware's implementation, and that there are no other expected
errors.
"""
- # Create an application.
- @webob.dec.wsgify
- def application(req):
- return 'Hello, World!!!'
-
# Bootstrap the application
self.application = NoRequestBase(application)
@@ -66,6 +58,16 @@ class TestBase(BaseTestCase):
self.assertTrue(self.application.called_without_request)
+ def test_paste_deploy_legacy(self):
+ app = LegacyMiddlewareTest.factory(
+ {'global': True}, local=True)(application)
+ self.assertEqual(app.conf, {})
+
+ def test_paste_deploy_configurable(self):
+ app = ConfigurableMiddlewareTest.factory(
+ {'global': True}, local=True)(application)
+ self.assertEqual(app.conf, {'global': True, 'local': True})
+
class NoRequestBase(Middleware):
"""Test middleware, implements old model."""
@@ -79,3 +81,11 @@ class RequestBase(Middleware):
def process_response(self, response, request):
self.called_with_request = True
return response
+
+
+class ConfigurableMiddlewareTest(ConfigurableMiddleware):
+ pass
+
+
+class LegacyMiddlewareTest(Middleware):
+ pass