diff options
author | Gordon Chung <gord@live.ca> | 2014-06-24 16:49:39 -0400 |
---|---|---|
committer | Gordon Chung <gord@live.ca> | 2014-06-24 16:49:39 -0400 |
commit | 5abab9ed0878f175f3396b33c76d9e9d94f748a6 (patch) | |
tree | 861addb97c360d5d492fccc6ba81d56946261b4c /tests | |
parent | 3d3da3e7a3d904dbd24a7bf56eced31ca81dc054 (diff) | |
download | oslo-middleware-5abab9ed0878f175f3396b33c76d9e9d94f748a6.tar.gz |
exported from oslo-incubator by graduate.sh
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 13 | ||||
-rw-r--r-- | tests/base.py | 54 | ||||
-rw-r--r-- | tests/test_middleware.py | 28 | ||||
-rw-r--r-- | tests/unit/middleware/test_catch_errors.py | 2 | ||||
-rw-r--r-- | tests/unit/middleware/test_correlation_id.py | 2 | ||||
-rw-r--r-- | tests/unit/middleware/test_request_id.py | 2 | ||||
-rw-r--r-- | tests/unit/middleware/test_sizelimit.py | 2 |
7 files changed, 99 insertions, 4 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..f88664e --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +# 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.
\ No newline at end of file diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..f9a09a8 --- /dev/null +++ b/tests/base.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010-2011 OpenStack Foundation +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# 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 os + +import fixtures +import testtools + +_TRUE_VALUES = ('true', '1', 'yes') + +# FIXME(dhellmann) Update this to use oslo.test library + +class TestCase(testtools.TestCase): + + """Test case base class for all unit tests.""" + + def setUp(self): + """Run before each test method to initialize test environment.""" + + super(TestCase, self).setUp() + test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0) + try: + test_timeout = int(test_timeout) + except ValueError: + # If timeout value is invalid do not set a timeout. + test_timeout = 0 + if test_timeout > 0: + self.useFixture(fixtures.Timeout(test_timeout, gentle=True)) + + self.useFixture(fixtures.NestedTempfile()) + self.useFixture(fixtures.TempHomeDir()) + + if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES: + stdout = self.useFixture(fixtures.StringStream('stdout')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout)) + if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES: + stderr = self.useFixture(fixtures.StringStream('stderr')).stream + self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr)) + + self.log_fixture = self.useFixture(fixtures.FakeLogger())
\ No newline at end of file diff --git a/tests/test_middleware.py b/tests/test_middleware.py new file mode 100644 index 0000000..ad7dce1 --- /dev/null +++ b/tests/test_middleware.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +# 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. + +""" +test_middleware +---------------------------------- + +Tests for `middleware` module. +""" + +from . import base + + +class TestMiddleware(base.TestCase): + + def test_something(self): + pass
\ No newline at end of file diff --git a/tests/unit/middleware/test_catch_errors.py b/tests/unit/middleware/test_catch_errors.py index f8b4c19..a14789d 100644 --- a/tests/unit/middleware/test_catch_errors.py +++ b/tests/unit/middleware/test_catch_errors.py @@ -18,7 +18,7 @@ from oslotest import base as test_base import webob.dec import webob.exc -from openstack.common.middleware import catch_errors +from oslo.middleware import catch_errors class CatchErrorsTest(test_base.BaseTestCase): diff --git a/tests/unit/middleware/test_correlation_id.py b/tests/unit/middleware/test_correlation_id.py index 3db9785..5248d8f 100644 --- a/tests/unit/middleware/test_correlation_id.py +++ b/tests/unit/middleware/test_correlation_id.py @@ -19,7 +19,7 @@ import mock from oslotest import base as test_base from oslotest import moxstubout -from openstack.common.middleware import correlation_id +from oslo.middleware import correlation_id class CorrelationIdMiddlewareTest(test_base.BaseTestCase): diff --git a/tests/unit/middleware/test_request_id.py b/tests/unit/middleware/test_request_id.py index 0185fda..c43229b 100644 --- a/tests/unit/middleware/test_request_id.py +++ b/tests/unit/middleware/test_request_id.py @@ -19,7 +19,7 @@ from testtools import matchers import webob import webob.dec -from openstack.common.middleware import request_id +from oslo.middleware import request_id class RequestIdTest(test_base.BaseTestCase): diff --git a/tests/unit/middleware/test_sizelimit.py b/tests/unit/middleware/test_sizelimit.py index 1bec469..8f571d9 100644 --- a/tests/unit/middleware/test_sizelimit.py +++ b/tests/unit/middleware/test_sizelimit.py @@ -17,7 +17,7 @@ import six import webob from openstack.common.fixture import config -from openstack.common.middleware import sizelimit +from oslo.middleware import sizelimit class TestLimitingReader(test_base.BaseTestCase): |