summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-03 14:10:35 +0000
committerGerrit Code Review <review@openstack.org>2015-06-03 14:10:35 +0000
commitf9fb2c4fb61444d7d780004996acf623e70bca21 (patch)
treebf7cc533c5268438235757d95727a9d7dc59e7bf
parentcab38ce307d1ebc34ba9ee6871acafaec28d75ee (diff)
parentbcbfceb716f7259a9a81e5750b60dc6ddc8f0a63 (diff)
downloadoslo-middleware-2.0.0.tar.gz
Merge "Remove oslo namespace package"2.0.0
-rw-r--r--oslo/__init__.py13
-rw-r--r--oslo/middleware/__init__.py28
-rw-r--r--oslo/middleware/base.py13
-rw-r--r--oslo/middleware/catch_errors.py13
-rw-r--r--oslo/middleware/correlation_id.py13
-rw-r--r--oslo/middleware/debug.py13
-rw-r--r--oslo/middleware/request_id.py13
-rw-r--r--oslo/middleware/sizelimit.py13
-rw-r--r--setup.cfg4
-rw-r--r--tests/__init__.py0
-rw-r--r--tests/test_catch_errors.py47
-rw-r--r--tests/test_correlation_id.py53
-rw-r--r--tests/test_request_id.py37
-rw-r--r--tests/test_sizelimit.py108
-rw-r--r--tests/test_warning.py61
15 files changed, 0 insertions, 429 deletions
diff --git a/oslo/__init__.py b/oslo/__init__.py
deleted file mode 100644
index dc130d6..0000000
--- a/oslo/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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__('pkg_resources').declare_namespace(__name__)
diff --git a/oslo/middleware/__init__.py b/oslo/middleware/__init__.py
deleted file mode 100644
index 1407ce1..0000000
--- a/oslo/middleware/__init__.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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 warnings
-
-from oslo_middleware import *
-
-
-def deprecated():
- new_name = __name__.replace('.', '_')
- warnings.warn(
- ('The oslo namespace package is deprecated. Please use %s instead.' %
- new_name),
- DeprecationWarning,
- stacklevel=3,
- )
-
-
-deprecated()
diff --git a/oslo/middleware/base.py b/oslo/middleware/base.py
deleted file mode 100644
index 53e25e9..0000000
--- a/oslo/middleware/base.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.base import * # noqa
diff --git a/oslo/middleware/catch_errors.py b/oslo/middleware/catch_errors.py
deleted file mode 100644
index 81e4c6c..0000000
--- a/oslo/middleware/catch_errors.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.catch_errors import * # noqa
diff --git a/oslo/middleware/correlation_id.py b/oslo/middleware/correlation_id.py
deleted file mode 100644
index fff548c..0000000
--- a/oslo/middleware/correlation_id.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.correlation_id import * # noqa
diff --git a/oslo/middleware/debug.py b/oslo/middleware/debug.py
deleted file mode 100644
index 2907289..0000000
--- a/oslo/middleware/debug.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.debug import * # noqa
diff --git a/oslo/middleware/request_id.py b/oslo/middleware/request_id.py
deleted file mode 100644
index 81e3164..0000000
--- a/oslo/middleware/request_id.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.request_id import * # noqa
diff --git a/oslo/middleware/sizelimit.py b/oslo/middleware/sizelimit.py
deleted file mode 100644
index c04c1cd..0000000
--- a/oslo/middleware/sizelimit.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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 oslo_middleware.sizelimit import * # noqa
diff --git a/setup.cfg b/setup.cfg
index 71103fe..e609b9a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -21,11 +21,7 @@ classifier =
[files]
packages =
- oslo
- oslo.middleware
oslo_middleware
-namespace_packages =
- oslo
[entry_points]
oslo.config.opts =
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/__init__.py
+++ /dev/null
diff --git a/tests/test_catch_errors.py b/tests/test_catch_errors.py
deleted file mode 100644
index 9e71f5b..0000000
--- a/tests/test_catch_errors.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (c) 2013 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
-from oslotest import base as test_base
-import webob.dec
-import webob.exc
-
-from oslo.middleware import catch_errors
-
-
-class CatchErrorsTest(test_base.BaseTestCase):
-
- def _test_has_request_id(self, application, expected_code=None):
- app = catch_errors.CatchErrors(application)
- req = webob.Request.blank('/test')
- res = req.get_response(app)
- self.assertEqual(expected_code, res.status_int)
-
- def test_success_response(self):
- @webob.dec.wsgify
- def application(req):
- return 'Hello, World!!!'
-
- self._test_has_request_id(application, webob.exc.HTTPOk.code)
-
- def test_internal_server_error(self):
- @webob.dec.wsgify
- def application(req):
- raise Exception()
-
- with mock.patch.object(catch_errors.LOG, 'exception') as log_exc:
- self._test_has_request_id(application,
- webob.exc.HTTPInternalServerError.code)
- self.assertEqual(1, log_exc.call_count)
diff --git a/tests/test_correlation_id.py b/tests/test_correlation_id.py
deleted file mode 100644
index b927e1d..0000000
--- a/tests/test_correlation_id.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (c) 2013 Rackspace Hosting
-# 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 uuid
-
-import mock
-from oslotest import base as test_base
-from oslotest import moxstubout
-
-from oslo.middleware import correlation_id
-
-
-class CorrelationIdTest(test_base.BaseTestCase):
-
- def setUp(self):
- super(CorrelationIdTest, self).setUp()
- self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
-
- def test_process_request(self):
- app = mock.Mock()
- req = mock.Mock()
- req.headers = {}
-
- mock_uuid4 = mock.Mock()
- mock_uuid4.return_value = "fake_uuid"
- self.stubs.Set(uuid, 'uuid4', mock_uuid4)
-
- middleware = correlation_id.CorrelationId(app)
- middleware(req)
-
- self.assertEqual(req.headers.get("X_CORRELATION_ID"), "fake_uuid")
-
- def test_process_request_should_not_regenerate_correlation_id(self):
- app = mock.Mock()
- req = mock.Mock()
- req.headers = {"X_CORRELATION_ID": "correlation_id"}
-
- middleware = correlation_id.CorrelationId(app)
- middleware(req)
-
- self.assertEqual(req.headers.get("X_CORRELATION_ID"), "correlation_id")
diff --git a/tests/test_request_id.py b/tests/test_request_id.py
deleted file mode 100644
index 549d7be..0000000
--- a/tests/test_request_id.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (c) 2013 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.
-
-
-from oslotest import base as test_base
-from testtools import matchers
-import webob
-import webob.dec
-
-from oslo.middleware import request_id
-
-
-class RequestIdTest(test_base.BaseTestCase):
- def test_generate_request_id(self):
- @webob.dec.wsgify
- def application(req):
- return req.environ[request_id.ENV_REQUEST_ID]
-
- app = request_id.RequestId(application)
- req = webob.Request.blank('/test')
- res = req.get_response(app)
- res_req_id = res.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID)
- self.assertThat(res_req_id, matchers.StartsWith(b'req-'))
- # request-id in request environ is returned as response body
- self.assertEqual(res_req_id, res.body)
diff --git a/tests/test_sizelimit.py b/tests/test_sizelimit.py
deleted file mode 100644
index 0f26a49..0000000
--- a/tests/test_sizelimit.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# Copyright (c) 2012 Red Hat, Inc.
-#
-# 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 oslotest import base as test_base
-import six
-import webob
-
-from oslo.config import fixture as config
-from oslo.middleware import sizelimit
-
-
-class TestLimitingReader(test_base.BaseTestCase):
-
- def test_limiting_reader(self):
- BYTES = 1024
- bytes_read = 0
- data = six.StringIO("*" * BYTES)
- for chunk in sizelimit.LimitingReader(data, BYTES):
- bytes_read += len(chunk)
-
- self.assertEqual(bytes_read, BYTES)
-
- bytes_read = 0
- data = six.StringIO("*" * BYTES)
- reader = sizelimit.LimitingReader(data, BYTES)
- byte = reader.read(1)
- while len(byte) != 0:
- bytes_read += 1
- byte = reader.read(1)
-
- self.assertEqual(bytes_read, BYTES)
-
- def test_read_default_value(self):
- BYTES = 1024
- data_str = "*" * BYTES
- data = six.StringIO(data_str)
- reader = sizelimit.LimitingReader(data, BYTES)
- res = reader.read()
- self.assertEqual(data_str, res)
-
- def test_limiting_reader_fails(self):
- BYTES = 1024
-
- def _consume_all_iter():
- bytes_read = 0
- data = six.StringIO("*" * BYTES)
- for chunk in sizelimit.LimitingReader(data, BYTES - 1):
- bytes_read += len(chunk)
-
- self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
- _consume_all_iter)
-
- def _consume_all_read():
- bytes_read = 0
- data = six.StringIO("*" * BYTES)
- reader = sizelimit.LimitingReader(data, BYTES - 1)
- byte = reader.read(1)
- while len(byte) != 0:
- bytes_read += 1
- byte = reader.read(1)
-
- self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
- _consume_all_read)
-
-
-class TestRequestBodySizeLimiter(test_base.BaseTestCase):
-
- def setUp(self):
- super(TestRequestBodySizeLimiter, self).setUp()
- fixture = self.useFixture(config.Config(sizelimit.CONF))
- self.MAX_REQUEST_BODY_SIZE = \
- fixture.conf.oslo_middleware.max_request_body_size
-
- @webob.dec.wsgify()
- def fake_app(req):
- return webob.Response(req.body)
-
- self.middleware = sizelimit.RequestBodySizeLimiter(fake_app)
- self.request = webob.Request.blank('/', method='POST')
-
- def test_content_length_acceptable(self):
- self.request.headers['Content-Length'] = self.MAX_REQUEST_BODY_SIZE
- self.request.body = b"0" * self.MAX_REQUEST_BODY_SIZE
- response = self.request.get_response(self.middleware)
- self.assertEqual(response.status_int, 200)
-
- def test_content_length_too_large(self):
- self.request.headers['Content-Length'] = self.MAX_REQUEST_BODY_SIZE + 1
- self.request.body = b"0" * (self.MAX_REQUEST_BODY_SIZE + 1)
- response = self.request.get_response(self.middleware)
- self.assertEqual(response.status_int, 413)
-
- def test_request_too_large_no_content_length(self):
- self.request.body = b"0" * (self.MAX_REQUEST_BODY_SIZE + 1)
- self.request.headers['Content-Length'] = None
- response = self.request.get_response(self.middleware)
- self.assertEqual(response.status_int, 413)
diff --git a/tests/test_warning.py b/tests/test_warning.py
deleted file mode 100644
index 8e7d96c..0000000
--- a/tests/test_warning.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# 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 imp
-import os
-import warnings
-
-import mock
-from oslotest import base as test_base
-import six
-
-
-class DeprecationWarningTest(test_base.BaseTestCase):
-
- @mock.patch('warnings.warn')
- def test_warning(self, mock_warn):
- import oslo.middleware
- imp.reload(oslo.middleware)
- self.assertTrue(mock_warn.called)
- args = mock_warn.call_args
- self.assertIn('oslo_middleware', args[0][0])
- self.assertIn('deprecated', args[0][0])
- self.assertTrue(issubclass(args[0][1], DeprecationWarning))
-
- def test_real_warning(self):
- with warnings.catch_warnings(record=True) as warning_msgs:
- warnings.resetwarnings()
- warnings.simplefilter('always', DeprecationWarning)
- import oslo.middleware
-
- # Use a separate function to get the stack level correct
- # so we know the message points back to this file. This
- # corresponds to an import or reload, which isn't working
- # inside the test under Python 3.3. That may be due to a
- # difference in the import implementation not triggering
- # warnings properly when the module is reloaded, or
- # because the warnings module is mostly implemented in C
- # and something isn't cleanly resetting the global state
- # used to track whether a warning needs to be
- # emitted. Whatever the cause, we definitely see the
- # warnings.warn() being invoked on a reload (see the test
- # above) and warnings are reported on the console when we
- # run the tests. A simpler test script run outside of
- # testr does correctly report the warnings.
- def foo():
- oslo.middleware.deprecated()
-
- foo()
- self.assertEqual(1, len(warning_msgs))
- msg = warning_msgs[0]
- self.assertIn('oslo_middleware', six.text_type(msg.message))
- self.assertEqual('test_warning.py', os.path.basename(msg.filename))