Common base class for unit tests
A common base class is defined to provide a place to put fixtures that affect all tests. For example, we could add a fixture that ensures that no deprecated function was used. Change-Id: I93aa45fa8284d8cdd8b0f71f137a261610e31988
This commit is contained in:
parent
c94f403490
commit
c9038c7d99
@ -1,4 +1,8 @@
|
||||
[DEFAULT]
|
||||
test_command=${PYTHON:-python} -m subunit.run discover -t ./ ./keystonemiddleware/tests $LISTOPT $IDOPTION
|
||||
test_command=
|
||||
OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ./keystonemiddleware/tests $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
@ -16,13 +16,13 @@ import fixtures
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
from requests_mock.contrib import fixture as rm_fixture
|
||||
import six
|
||||
import testtools
|
||||
import webob.dec
|
||||
|
||||
from keystonemiddleware import auth_token
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class BaseAuthTokenTestCase(testtools.TestCase):
|
||||
class BaseAuthTokenTestCase(utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(BaseAuthTokenTestCase, self).setUp()
|
||||
|
@ -18,12 +18,12 @@ from keystoneclient import fixture
|
||||
from keystoneclient import session
|
||||
from requests_mock.contrib import fixture as rm_fixture
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from keystonemiddleware.auth_token import _auth
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class DefaultAuthPluginTests(testtools.TestCase):
|
||||
class DefaultAuthPluginTests(utils.BaseTestCase):
|
||||
|
||||
def new_plugin(self, auth_host=None, auth_port=None, auth_protocol=None,
|
||||
auth_admin_prefix=None, admin_user=None,
|
||||
|
@ -11,12 +11,12 @@
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from keystonemiddleware.auth_token import _memcache_crypt as memcache_crypt
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class MemcacheCryptPositiveTests(testtools.TestCase):
|
||||
class MemcacheCryptPositiveTests(utils.BaseTestCase):
|
||||
def _setup_keys(self, strategy):
|
||||
return memcache_crypt.derive_keys(b'token', b'secret', strategy)
|
||||
|
||||
|
@ -18,14 +18,14 @@ import shutil
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from keystonemiddleware.auth_token import _exceptions as exc
|
||||
from keystonemiddleware.auth_token import _revocations
|
||||
from keystonemiddleware.auth_token import _signing_dir
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class RevocationsTests(testtools.TestCase):
|
||||
class RevocationsTests(utils.BaseTestCase):
|
||||
|
||||
def _check_with_list(self, revoked_list, token_ids):
|
||||
directory_name = '/tmp/%s' % uuid.uuid4().hex
|
||||
|
@ -15,12 +15,11 @@ import shutil
|
||||
import stat
|
||||
import uuid
|
||||
|
||||
import testtools
|
||||
|
||||
from keystonemiddleware.auth_token import _signing_dir
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class SigningDirectoryTests(testtools.TestCase):
|
||||
class SigningDirectoryTests(utils.BaseTestCase):
|
||||
|
||||
def test_directory_created_when_doesnt_exist(self):
|
||||
# When _SigningDirectory is created, if the directory doesn't exist
|
||||
|
@ -18,11 +18,11 @@ import uuid
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from pycadf import identifier
|
||||
import testtools
|
||||
from testtools import matchers
|
||||
import webob
|
||||
|
||||
from keystonemiddleware import audit
|
||||
from keystonemiddleware.tests.unit import utils
|
||||
|
||||
|
||||
class FakeApp(object):
|
||||
@ -40,7 +40,7 @@ class FakeFailingApp(object):
|
||||
raise Exception('It happens!')
|
||||
|
||||
|
||||
class BaseAuditMiddlewareTest(testtools.TestCase):
|
||||
class BaseAuditMiddlewareTest(utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(BaseAuditMiddlewareTest, self).setUp()
|
||||
self.fd, self.audit_map = tempfile.mkstemp()
|
||||
|
@ -17,7 +17,6 @@ from oslo_serialization import jsonutils
|
||||
import requests
|
||||
from requests_mock.contrib import fixture as rm_fixture
|
||||
import six
|
||||
import testtools
|
||||
import webob
|
||||
|
||||
from keystonemiddleware import s3_token
|
||||
@ -222,7 +221,7 @@ class S3TokenMiddlewareTestBad(S3TokenMiddlewareTestBase):
|
||||
self.assertEqual(resp.status_int, s3_invalid_req.status_int)
|
||||
|
||||
|
||||
class S3TokenMiddlewareTestUtil(testtools.TestCase):
|
||||
class S3TokenMiddlewareTestUtil(utils.BaseTestCase):
|
||||
def test_split_path_failed(self):
|
||||
self.assertRaises(ValueError, s3_token._split_path, '')
|
||||
self.assertRaises(ValueError, s3_token._split_path, '/')
|
||||
|
@ -16,12 +16,16 @@ import time
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
import oslotest.base as oslotest
|
||||
import requests
|
||||
import testtools
|
||||
import uuid
|
||||
|
||||
|
||||
class TestCase(testtools.TestCase):
|
||||
class BaseTestCase(oslotest.BaseTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestCase(BaseTestCase):
|
||||
TEST_DOMAIN_ID = '1'
|
||||
TEST_DOMAIN_NAME = 'aDomain'
|
||||
TEST_GROUP_ID = uuid.uuid4().hex
|
||||
|
Loading…
x
Reference in New Issue
Block a user