Change tests to use common name for keystone.tests.unit

In several test files, the keystone.tests.unit import was aliased as
tests. This made it difficult to do global renames. 

Change-Id: I1e4798c76d53f265b921ef26e2a0141fc504ce69
This commit is contained in:
Brant Knudson 2015-08-30 10:51:31 -05:00 committed by Morgan Fainberg
parent a4614b3151
commit 93b7f95625
64 changed files with 297 additions and 298 deletions

View File

@ -17,7 +17,7 @@ from oslo_config import cfg
from keystone.common import cache
from keystone.common import ldap as common_ldap
from keystone.common.ldap import core as common_ldap_core
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit import fakeldap
from keystone.tests.unit.ksfixtures import database
@ -66,7 +66,7 @@ class BaseBackendLdapCommon(object):
def config_files(self):
config_files = super(BaseBackendLdapCommon, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
def get_user_enabled_vals(self, user):
@ -99,13 +99,13 @@ class BaseBackendLdap(object):
super(BaseBackendLdap, self).load_fixtures(fixtures)
class BaseBackendLdapIdentitySqlEverythingElse(tests.SQLDriverOverrides):
class BaseBackendLdapIdentitySqlEverythingElse(unit.SQLDriverOverrides):
"""Mixin base for Identity LDAP, everything else SQL backend tests."""
def config_files(self):
config_files = super(BaseBackendLdapIdentitySqlEverythingElse,
self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap_sql.conf'))
return config_files
def setUp(self):

View File

@ -13,12 +13,12 @@
import sqlalchemy
from keystone.common import sql
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
class BaseBackendSqlTests(tests.SQLDriverOverrides, tests.TestCase):
class BaseBackendSqlTests(unit.SQLDriverOverrides, unit.TestCase):
def setUp(self):
super(BaseBackendSqlTests, self).setUp()
@ -32,7 +32,7 @@ class BaseBackendSqlTests(tests.SQLDriverOverrides, tests.TestCase):
def config_files(self):
config_files = super(BaseBackendSqlTests, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files

View File

@ -17,7 +17,7 @@ import mock
from testtools import matchers
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
class DomainConfigTests(object):
@ -523,7 +523,7 @@ class DomainConfigTests(object):
# The escaping '%' should have been removed
self.assertEqual('my_url/%(password)s', res['ldap']['url'])
@tests.skip_if_cache_disabled('domain_config')
@unit.skip_if_cache_disabled('domain_config')
def test_cache_layer_get_sensitive_config(self):
config = {'ldap': {'url': uuid.uuid4().hex,
'user_tree_dn': uuid.uuid4().hex,

View File

@ -16,7 +16,7 @@ import copy
import uuid
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
@ -87,7 +87,7 @@ class RoleTests(object):
expected_role_ids = set(role['id'] for role in default_fixtures.ROLES)
self.assertEqual(expected_role_ids, role_ids)
@tests.skip_if_cache_disabled('role')
@unit.skip_if_cache_disabled('role')
def test_cache_layer_role_crud(self):
role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
role_id = role['id']

View File

@ -16,7 +16,7 @@ import uuid
from oslo_config import cfg
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.backend import core_ldap
from keystone.tests.unit.backend.role import core as core_role
from keystone.tests.unit import default_fixtures
@ -35,7 +35,7 @@ class LdapRoleCommon(core_ldap.BaseBackendLdapCommon, core_role.RoleTests):
pass
class LdapRole(LdapRoleCommon, core_ldap.BaseBackendLdap, tests.TestCase):
class LdapRole(LdapRoleCommon, core_ldap.BaseBackendLdap, unit.TestCase):
"""Test in an all-LDAP configuration.
Include additional tests that are unique to LDAP (or need to be overridden)
@ -149,7 +149,7 @@ class LdapRole(LdapRoleCommon, core_ldap.BaseBackendLdap, tests.TestCase):
class LdapIdentitySqlEverythingElseRole(
core_ldap.BaseBackendLdapIdentitySqlEverythingElse, LdapRoleCommon,
tests.TestCase):
unit.TestCase):
"""Test Identity in LDAP, Everything else in SQL."""
pass

View File

@ -13,7 +13,7 @@
# under the License.
from keystone.common import base64utils
from keystone.tests import unit as tests
from keystone.tests import unit
base64_alphabet = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz'
@ -26,7 +26,7 @@ base64url_alphabet = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'-_=') # includes pad char
class TestValid(tests.BaseTestCase):
class TestValid(unit.BaseTestCase):
def test_valid_base64(self):
self.assertTrue(base64utils.is_valid_base64('+/=='))
self.assertTrue(base64utils.is_valid_base64('+/+='))
@ -68,7 +68,7 @@ class TestValid(tests.BaseTestCase):
self.assertTrue(base64utils.is_valid_base64url('-_=='))
class TestBase64Padding(tests.BaseTestCase):
class TestBase64Padding(unit.BaseTestCase):
def test_filter(self):
self.assertEqual('', base64utils.filter_formatting(''))
@ -189,7 +189,7 @@ class TestBase64Padding(tests.BaseTestCase):
base64utils.base64url_percent_decode, 'AB%3D%3')
class TestTextWrap(tests.BaseTestCase):
class TestTextWrap(unit.BaseTestCase):
def test_wrapping(self):
raw_text = 'abcdefgh'

View File

@ -15,10 +15,10 @@
import uuid
from keystone.common import dependency
from keystone.tests import unit as tests
from keystone.tests import unit
class TestDependencyInjection(tests.BaseTestCase):
class TestDependencyInjection(unit.BaseTestCase):
def setUp(self):
super(TestDependencyInjection, self).setUp()
dependency.reset()

View File

@ -18,10 +18,10 @@ import copy
from testtools import matchers
from keystone.common import json_home
from keystone.tests import unit as tests
from keystone.tests import unit
class JsonHomeTest(tests.BaseTestCase):
class JsonHomeTest(unit.BaseTestCase):
def test_build_v3_resource_relation(self):
resource_name = self.getUniqueString()
relation = json_home.build_v3_resource_relation(resource_name)

View File

@ -24,7 +24,7 @@ from testtools import matchers
from keystone.common import driver_hints
from keystone.common import ldap as ks_ldap
from keystone.common.ldap import core as common_ldap_core
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit import fakeldap
@ -32,7 +32,7 @@ from keystone.tests.unit import fakeldap
CONF = cfg.CONF
class DnCompareTest(tests.BaseTestCase):
class DnCompareTest(unit.BaseTestCase):
"""Tests for the DN comparison functions in keystone.common.ldap.core."""
def test_prep(self):
@ -200,7 +200,7 @@ class DnCompareTest(tests.BaseTestCase):
self.assertTrue(ks_ldap.dn_startswith(child, parent))
class LDAPDeleteTreeTest(tests.TestCase):
class LDAPDeleteTreeTest(unit.TestCase):
def setUp(self):
super(LDAPDeleteTreeTest, self).setUp()
@ -223,7 +223,7 @@ class LDAPDeleteTreeTest(tests.TestCase):
def config_files(self):
config_files = super(LDAPDeleteTreeTest, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
def test_deleteTree(self):
@ -283,7 +283,7 @@ class LDAPDeleteTreeTest(tests.TestCase):
conn.search_s, grandchild_dn, ldap.SCOPE_BASE)
class SslTlsTest(tests.TestCase):
class SslTlsTest(unit.TestCase):
"""Tests for the SSL/TLS functionality in keystone.common.ldap.core."""
@mock.patch.object(ks_ldap.core.KeystoneLDAPHandler, 'simple_bind_s')
@ -350,7 +350,7 @@ class SslTlsTest(tests.TestCase):
self.assertEqual(certdir, ldap.get_option(ldap.OPT_X_TLS_CACERTDIR))
class LDAPPagedResultsTest(tests.TestCase):
class LDAPPagedResultsTest(unit.TestCase):
"""Tests the paged results functionality in keystone.common.ldap.core."""
def setUp(self):
@ -373,7 +373,7 @@ class LDAPPagedResultsTest(tests.TestCase):
def config_files(self):
config_files = super(LDAPPagedResultsTest, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
@mock.patch.object(fakeldap.FakeLdap, 'search_ext')
@ -390,7 +390,7 @@ class LDAPPagedResultsTest(tests.TestCase):
'objectclass=*')
class CommonLdapTestCase(tests.BaseTestCase):
class CommonLdapTestCase(unit.BaseTestCase):
"""These test cases call functions in keystone.common.ldap."""
def test_binary_attribute_values(self):
@ -497,7 +497,7 @@ class CommonLdapTestCase(tests.BaseTestCase):
self.assertEqual(user_name, py_result[0][1]['user_name'][0])
class LDAPFilterQueryCompositionTest(tests.TestCase):
class LDAPFilterQueryCompositionTest(unit.TestCase):
"""These test cases test LDAP filter generation."""
def setUp(self):

View File

@ -14,7 +14,7 @@
from sqlalchemy.ext import declarative
from keystone.common import sql
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import utils
@ -27,7 +27,7 @@ class TestModel(ModelBase, sql.ModelDictMixin):
text = sql.Column(sql.String(64), nullable=False)
class TestModelDictMixin(tests.BaseTestCase):
class TestModelDictMixin(unit.BaseTestCase):
def test_creating_a_model_instance_from_a_dict(self):
d = {'id': utils.new_uuid(), 'text': utils.new_uuid()}

View File

@ -20,7 +20,7 @@ from oslo_serialization import jsonutils
from keystone.common import utils as common_utils
from keystone import exception
from keystone import service
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import utils
@ -29,7 +29,7 @@ CONF = cfg.CONF
TZ = utils.TZ
class UtilsTestCase(tests.BaseTestCase):
class UtilsTestCase(unit.BaseTestCase):
OPTIONAL = object()
def setUp(self):
@ -154,11 +154,11 @@ class UtilsTestCase(tests.BaseTestCase):
self.assertEqual(expected_json, json)
class ServiceHelperTests(tests.BaseTestCase):
class ServiceHelperTests(unit.BaseTestCase):
@service.fail_gracefully
def _do_test(self):
raise Exception("Test Exc")
def test_fail_gracefully(self):
self.assertRaises(tests.UnexpectedExit, self._do_test)
self.assertRaises(unit.UnexpectedExit, self._do_test)

View File

@ -22,20 +22,20 @@ from oslo_config import fixture as config_fixture
from keystone import exception
from keystone import identity
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import database
CONF = cfg.CONF
class TestDomainConfigs(tests.BaseTestCase):
class TestDomainConfigs(unit.BaseTestCase):
def setUp(self):
super(TestDomainConfigs, self).setUp()
self.addCleanup(CONF.reset)
self.tmp_dir = tests.dirs.tmp()
self.tmp_dir = unit.dirs.tmp()
self.config_fixture = self.useFixture(config_fixture.Config(CONF))
self.config_fixture.config(domain_config_dir=self.tmp_dir,
@ -125,7 +125,7 @@ class TestDomainConfigs(tests.BaseTestCase):
self.assertEqual(3, load_driver_mock.call_count)
class TestDatabaseDomainConfigs(tests.TestCase):
class TestDatabaseDomainConfigs(unit.TestCase):
def setUp(self):
super(TestDatabaseDomainConfigs, self).setUp()

View File

@ -19,7 +19,7 @@ from oslo_config import cfg
from oslo_db import options as db_options
from keystone.common import sql
from keystone.tests import unit as tests
from keystone.tests import unit
CONF = cfg.CONF
@ -47,7 +47,7 @@ def initialize_sql_session():
# test cases.
db_options.set_defaults(
CONF,
connection=tests.IN_MEM_DB_CONN_STRING)
connection=unit.IN_MEM_DB_CONN_STRING)
@run_once

View File

@ -16,12 +16,12 @@ from oslo_serialization import jsonutils
import webtest
from keystone.auth import controllers as auth_controllers
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
class RestfulTestCase(tests.TestCase):
class RestfulTestCase(unit.TestCase):
"""Performs restful tests against the WSGI app over HTTP.
This class launches public & admin WSGI servers for every test, which can

View File

@ -29,7 +29,7 @@ from keystone.common import authorization
from keystone import config
from keystone import exception
from keystone.models import token_model
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
from keystone import token
@ -72,7 +72,7 @@ def _build_user_auth(token=None, user_id=None, username=None,
return auth_json
class AuthTest(tests.TestCase):
class AuthTest(unit.TestCase):
def setUp(self):
self.useFixture(database.Database())
super(AuthTest, self).setUp()
@ -1285,14 +1285,14 @@ class TokenExpirationTest(AuthTest):
self._maintain_token_expiration()
class AuthCatalog(tests.SQLDriverOverrides, AuthTest):
class AuthCatalog(unit.SQLDriverOverrides, AuthTest):
"""Tests for the catalog provided in the auth response."""
def config_files(self):
config_files = super(AuthCatalog, self).config_files()
# We need to use a backend that supports disabled endpoints, like the
# SQL backend.
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def _create_endpoints(self):
@ -1402,7 +1402,7 @@ class AuthCatalog(tests.SQLDriverOverrides, AuthTest):
self.assertEqual(exp_endpoint, endpoint)
class NonDefaultAuthTest(tests.TestCase):
class NonDefaultAuthTest(unit.TestCase):
def test_add_non_default_auth_method(self):
self.config_fixture.config(group='auth',

View File

@ -18,7 +18,7 @@ import mock
from keystone import auth
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
# for testing purposes only
@ -37,7 +37,7 @@ class SimpleChallengeResponse(auth.AuthMethodHandler):
return {"challenge": "What's the name of your high school?"}
class TestAuthPlugin(tests.SQLDriverOverrides, tests.TestCase):
class TestAuthPlugin(unit.SQLDriverOverrides, unit.TestCase):
def setUp(self):
super(TestAuthPlugin, self).setUp()
self.load_backends()
@ -121,11 +121,11 @@ class TestAuthPluginDynamicOptions(TestAuthPlugin):
def config_files(self):
config_files = super(TestAuthPluginDynamicOptions, self).config_files()
config_files.append(tests.dirs.tests_conf('test_auth_plugin.conf'))
config_files.append(unit.dirs.tests_conf('test_auth_plugin.conf'))
return config_files
class TestMapped(tests.TestCase):
class TestMapped(unit.TestCase):
def setUp(self):
super(TestMapped, self).setUp()
self.load_backends()
@ -134,7 +134,7 @@ class TestMapped(tests.TestCase):
def config_files(self):
config_files = super(TestMapped, self).config_files()
config_files.append(tests.dirs.tests_conf('test_auth_plugin.conf'))
config_files.append(unit.dirs.tests_conf('test_auth_plugin.conf'))
return config_files
def auth_plugin_config_override(self, methods=None, **method_classes):

View File

@ -28,7 +28,7 @@ from testtools import matchers
from keystone.catalog import core
from keystone.common import driver_hints
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit import filtering
from keystone.tests.unit import utils as test_utils
@ -543,7 +543,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.user_foo.pop('password')
self.assertDictEqual(user_ref, self.user_foo)
@tests.skip_if_cache_disabled('identity')
@unit.skip_if_cache_disabled('identity')
def test_cache_layer_get_user(self):
user = {
'name': uuid.uuid4().hex.lower(),
@ -595,7 +595,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.user_foo.pop('password')
self.assertDictEqual(user_ref, self.user_foo)
@tests.skip_if_cache_disabled('identity')
@unit.skip_if_cache_disabled('identity')
def test_cache_layer_get_user_by_name(self):
user = {
'name': uuid.uuid4().hex.lower(),
@ -2469,7 +2469,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.assertIn(self.tenant_mtu['id'], project_ids)
self.assertIn(self.tenant_service['id'], project_ids)
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_list_projects_for_alternate_domain(self):
domain1 = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
self.resource_api.create_domain(domain1['id'], domain1)
@ -2526,7 +2526,7 @@ class IdentityTests(AssignmentTestHelperMixin):
return projects
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_create_domain_with_project_api(self):
project_id = uuid.uuid4().hex
project = {'id': project_id,
@ -2540,7 +2540,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.assertTrue(ref['is_domain'])
self.assertEqual(DEFAULT_DOMAIN_ID, ref['domain_id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
@test_utils.wip('waiting for projects acting as domains implementation')
def test_is_domain_sub_project_has_parent_domain_id(self):
project = {'id': uuid.uuid4().hex,
@ -2565,7 +2565,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.assertEqual(project['id'], ref['parent_id'])
self.assertEqual(project['id'], ref['domain_id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
@test_utils.wip('waiting for projects acting as domains implementation')
def test_delete_domain_with_project_api(self):
project_id = uuid.uuid4().hex
@ -2590,7 +2590,7 @@ class IdentityTests(AssignmentTestHelperMixin):
# Successfuly delete the project
self.resource_api.delete_project(project['id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
@test_utils.wip('waiting for projects acting as domains implementation')
def test_create_domain_under_regular_project_hierarchy_fails(self):
# Creating a regular project hierarchy. Projects acting as domains
@ -2610,7 +2610,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.resource_api.create_project,
project['id'], project)
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
@test_utils.wip('waiting for projects acting as domains implementation')
def test_create_project_under_domain_hierarchy(self):
projects_hierarchy = self._create_projects_hierarchy(is_domain=True)
@ -3224,7 +3224,7 @@ class IdentityTests(AssignmentTestHelperMixin):
uuid.uuid4().hex,
DEFAULT_DOMAIN_ID)
@tests.skip_if_cache_disabled('identity')
@unit.skip_if_cache_disabled('identity')
def test_cache_layer_group_crud(self):
group = {'domain_id': DEFAULT_DOMAIN_ID, 'name': uuid.uuid4().hex}
group = self.identity_api.create_group(group)
@ -3299,7 +3299,7 @@ class IdentityTests(AssignmentTestHelperMixin):
group1['id'],
group1)
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_project_crud(self):
domain = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex,
'enabled': True}
@ -3400,7 +3400,7 @@ class IdentityTests(AssignmentTestHelperMixin):
project['id'],
project)
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_create_leaf_project_with_different_domain(self):
root_project = {'id': uuid.uuid4().hex,
'name': uuid.uuid4().hex,
@ -3615,7 +3615,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.resource_api.get_domain,
domain['id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_create_domain_case_sensitivity(self):
# create a ref with a lowercase name
ref = {
@ -3750,8 +3750,8 @@ class IdentityTests(AssignmentTestHelperMixin):
user_projects = self.assignment_api.list_projects_for_user(user1['id'])
self.assertEqual(3, len(user_projects))
@tests.skip_if_cache_disabled('resource')
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_cache_disabled('resource')
@unit.skip_if_no_multiple_domains_support
def test_domain_rename_invalidates_get_domain_by_name_cache(self):
domain = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex,
'enabled': True}
@ -3765,7 +3765,7 @@ class IdentityTests(AssignmentTestHelperMixin):
self.resource_api.get_domain_by_name,
domain_name)
@tests.skip_if_cache_disabled('resource')
@unit.skip_if_cache_disabled('resource')
def test_cache_layer_domain_crud(self):
domain = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex,
'enabled': True}
@ -3820,8 +3820,8 @@ class IdentityTests(AssignmentTestHelperMixin):
self.resource_api.get_domain,
domain_id)
@tests.skip_if_cache_disabled('resource')
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_cache_disabled('resource')
@unit.skip_if_no_multiple_domains_support
def test_project_rename_invalidates_get_project_by_name_cache(self):
domain = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex,
'enabled': True}
@ -3840,8 +3840,8 @@ class IdentityTests(AssignmentTestHelperMixin):
project_name,
domain['id'])
@tests.skip_if_cache_disabled('resource')
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_cache_disabled('resource')
@unit.skip_if_no_multiple_domains_support
def test_cache_layer_project_crud(self):
domain = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex,
'enabled': True}
@ -3953,7 +3953,7 @@ class IdentityTests(AssignmentTestHelperMixin):
group_id=uuid.uuid4().hex,
project_id=self.tenant_bar['id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_get_default_domain_by_name(self):
domain_name = 'default'
@ -4646,7 +4646,7 @@ class TokenTests(object):
self.assertEqual(1, len(tokens))
self.assertIn(token_id, tokens)
@tests.skip_if_cache_disabled('token')
@unit.skip_if_cache_disabled('token')
def test_revocation_list_cache(self):
expire_time = timeutils.utcnow() + datetime.timedelta(minutes=10)
token_id = uuid.uuid4().hex
@ -5076,7 +5076,7 @@ class CatalogTests(object):
for region in regions:
self.assertEqual(parent_id, region['parent_region_id'])
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_cache_layer_region_crud(self):
region_id = uuid.uuid4().hex
new_region = {
@ -5104,7 +5104,7 @@ class CatalogTests(object):
self.assertRaises(exception.RegionNotFound,
self.catalog_api.get_region, region_id)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_region(self):
region_id = uuid.uuid4().hex
new_region = {
@ -5310,7 +5310,7 @@ class CatalogTests(object):
self.catalog_api.delete_service(unrelated_service1['id'])
self.catalog_api.delete_service(unrelated_service2['id'])
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_cache_layer_service_crud(self):
service_id = uuid.uuid4().hex
new_service = {
@ -5347,7 +5347,7 @@ class CatalogTests(object):
self.catalog_api.get_service,
service_id)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_service(self):
service_id = uuid.uuid4().hex
new_service = {
@ -5658,7 +5658,7 @@ class CatalogTests(object):
endpoint_ids = [x['id'] for x in catalog[0]['endpoints']]
self.assertEqual([enabled_endpoint_ref['id']], endpoint_ids)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_endpoint(self):
service = {
'id': uuid.uuid4().hex,

View File

@ -20,14 +20,14 @@ import six
from keystone.common import utils
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_backend
CONF = cfg.CONF
class KvsToken(tests.TestCase, test_backend.TokenTests):
class KvsToken(unit.TestCase, test_backend.TokenTests):
def setUp(self):
super(KvsToken, self).setUp()
self.load_backends()
@ -103,7 +103,7 @@ class KvsToken(tests.TestCase, test_backend.TokenTests):
self.assertEqual(expected_user_token_list, user_token_list)
class KvsCatalog(tests.TestCase, test_backend.CatalogTests):
class KvsCatalog(unit.TestCase, test_backend.CatalogTests):
def setUp(self):
super(KvsCatalog, self).setUp()
self.load_backends()
@ -157,7 +157,7 @@ class KvsCatalog(tests.TestCase, test_backend.CatalogTests):
self.skipTest("kvs backend doesn't support filtering")
class KvsTokenCacheInvalidation(tests.TestCase,
class KvsTokenCacheInvalidation(unit.TestCase,
test_backend.TokenCacheInvalidation):
def setUp(self):
super(KvsTokenCacheInvalidation, self).setUp()

View File

@ -31,7 +31,7 @@ from keystone import exception
from keystone import identity
from keystone.identity.mapping_backends import mapping as map
from keystone import resource
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit import identity_mapping as mapping_sql
from keystone.tests.unit.ksfixtures import database
@ -138,7 +138,7 @@ class BaseLDAPIdentity(test_backend.IdentityTests):
def config_files(self):
config_files = super(BaseLDAPIdentity, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
def get_user_enabled_vals(self, user):
@ -712,7 +712,7 @@ class BaseLDAPIdentity(test_backend.IdentityTests):
self.identity_api.get_group,
group['id'])
@tests.skip_if_cache_disabled('identity')
@unit.skip_if_cache_disabled('identity')
def test_cache_layer_group_crud(self):
group = {
'domain_id': CONF.identity.default_domain_id,
@ -993,7 +993,7 @@ class BaseLDAPIdentity(test_backend.IdentityTests):
test_list_role_assignment_by_user_with_domain_group_roles)
class LDAPIdentity(BaseLDAPIdentity, tests.TestCase):
class LDAPIdentity(BaseLDAPIdentity, unit.TestCase):
def setUp(self):
# NOTE(dstanek): The database must be setup prior to calling the
@ -1591,7 +1591,7 @@ class LDAPIdentity(BaseLDAPIdentity, tests.TestCase):
self.resource_api.get_domain,
domain['id'])
@tests.skip_if_no_multiple_domains_support
@unit.skip_if_no_multiple_domains_support
def test_create_domain_case_sensitivity(self):
# domains are read-only, so case sensitivity isn't an issue
ref = {
@ -1646,7 +1646,7 @@ class LDAPIdentity(BaseLDAPIdentity, tests.TestCase):
self.resource_api.get_project,
project['id'])
@tests.skip_if_cache_disabled('assignment')
@unit.skip_if_cache_disabled('assignment')
def test_cache_layer_project_crud(self):
# NOTE(morganfainberg): LDAP implementation does not currently support
# updating project names. This method override provides a different
@ -2104,7 +2104,7 @@ class LDAPIdentityEnabledEmulation(LDAPIdentity):
def config_files(self):
config_files = super(LDAPIdentityEnabledEmulation, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
def config_overrides(self):
@ -2263,12 +2263,12 @@ class LDAPIdentityEnabledEmulation(LDAPIdentity):
self.assertIs(False, user_ref['enabled'])
class LdapIdentitySqlAssignment(BaseLDAPIdentity, tests.SQLDriverOverrides,
tests.TestCase):
class LdapIdentitySqlAssignment(BaseLDAPIdentity, unit.SQLDriverOverrides,
unit.TestCase):
def config_files(self):
config_files = super(LdapIdentitySqlAssignment, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap_sql.conf'))
return config_files
def setUp(self):
@ -2531,8 +2531,8 @@ class BaseMultiLDAPandSQLIdentity(object):
password=self.users[user]['password'])
class MultiLDAPandSQLIdentity(BaseLDAPIdentity, tests.SQLDriverOverrides,
tests.TestCase, BaseMultiLDAPandSQLIdentity):
class MultiLDAPandSQLIdentity(BaseLDAPIdentity, unit.SQLDriverOverrides,
unit.TestCase, BaseMultiLDAPandSQLIdentity):
"""Class to test common SQL plus individual LDAP backends.
We define a set of domains and domain-specific backends:
@ -2611,7 +2611,7 @@ class MultiLDAPandSQLIdentity(BaseLDAPIdentity, tests.SQLDriverOverrides,
"""
self.config_fixture.config(
group='identity', domain_specific_drivers_enabled=True,
domain_config_dir=tests.TESTCONF + '/domain_configs_multi_ldap')
domain_config_dir=unit.TESTCONF + '/domain_configs_multi_ldap')
self.config_fixture.config(group='identity_mapping',
backward_compatible_ids=False)
@ -2955,7 +2955,7 @@ class MultiLDAPandSQLIdentityDomainConfigsInSQL(MultiLDAPandSQLIdentity):
class DomainSpecificLDAPandSQLIdentity(
BaseLDAPIdentity, tests.SQLDriverOverrides, tests.TestCase,
BaseLDAPIdentity, unit.SQLDriverOverrides, unit.TestCase,
BaseMultiLDAPandSQLIdentity):
"""Class to test when all domains use specific configs, including SQL.
@ -2978,7 +2978,7 @@ class DomainSpecificLDAPandSQLIdentity(
self.config_fixture.config(
group='identity', domain_specific_drivers_enabled=True,
domain_config_dir=(
tests.TESTCONF + '/domain_configs_one_sql_one_ldap'))
unit.TESTCONF + '/domain_configs_one_sql_one_ldap'))
self.config_fixture.config(group='identity_mapping',
backward_compatible_ids=False)
@ -3137,7 +3137,7 @@ class DomainSpecificSQLIdentity(DomainSpecificLDAPandSQLIdentity):
self.config_fixture.config(
group='identity', domain_specific_drivers_enabled=True,
domain_config_dir=(
tests.TESTCONF + '/domain_configs_default_ldap_one_sql'))
unit.TESTCONF + '/domain_configs_default_ldap_one_sql'))
# Part of the testing counts how many new mappings get created as
# we create users, so ensure we are NOT using mapping for the default
# LDAP domain so this doesn't confuse the calculation.
@ -3213,12 +3213,12 @@ class DomainSpecificSQLIdentity(DomainSpecificLDAPandSQLIdentity):
exception.MultipleSQLDriversInConfig,
self.identity_api.domain_configs._load_config_from_file,
self.resource_api,
[tests.TESTCONF + '/domain_configs_one_extra_sql/' +
[unit.TESTCONF + '/domain_configs_one_extra_sql/' +
'keystone.domain2.conf'],
'domain2')
class LdapFilterTests(test_backend.FilterTests, tests.TestCase):
class LdapFilterTests(test_backend.FilterTests, unit.TestCase):
def setUp(self):
super(LdapFilterTests, self).setUp()
@ -3236,7 +3236,7 @@ class LdapFilterTests(test_backend.FilterTests, tests.TestCase):
def config_files(self):
config_files = super(LdapFilterTests, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap.conf'))
return config_files
def test_list_users_in_group_filtered(self):

View File

@ -21,7 +21,7 @@ from oslotest import mockpatch
from keystone.common.ldap import core as ldap_core
from keystone.identity.backends import ldap
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import fakeldap
from keystone.tests.unit import test_backend_ldap
@ -209,7 +209,7 @@ class LdapPoolCommonTestMixin(object):
class LdapIdentitySqlAssignment(LdapPoolCommonTestMixin,
test_backend_ldap.LdapIdentitySqlAssignment,
tests.TestCase):
unit.TestCase):
"""Executes tests in existing base class with pooled LDAP handler."""
def setUp(self):
self.useFixture(mockpatch.PatchObject(
@ -226,7 +226,7 @@ class LdapIdentitySqlAssignment(LdapPoolCommonTestMixin,
def config_files(self):
config_files = super(LdapIdentitySqlAssignment, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_ldap_pool.conf'))
config_files.append(unit.dirs.tests_conf('backend_ldap_pool.conf'))
return config_files
@mock.patch.object(ldap_core, 'utf8_encode')

View File

@ -14,11 +14,11 @@
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_backend
class RulesPolicy(tests.TestCase, test_backend.PolicyTests):
class RulesPolicy(unit.TestCase, test_backend.PolicyTests):
def setUp(self):
super(RulesPolicy, self).setUp()
self.load_backends()

View File

@ -29,7 +29,7 @@ from keystone.common import driver_hints
from keystone.common import sql
from keystone import exception
from keystone.identity.backends import sql as identity_sql
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
from keystone.tests.unit import test_backend
@ -40,7 +40,7 @@ CONF = cfg.CONF
DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id
class SqlTests(tests.SQLDriverOverrides, tests.TestCase):
class SqlTests(unit.SQLDriverOverrides, unit.TestCase):
def setUp(self):
super(SqlTests, self).setUp()
@ -54,7 +54,7 @@ class SqlTests(tests.SQLDriverOverrides, tests.TestCase):
def config_files(self):
config_files = super(SqlTests, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
@ -840,7 +840,7 @@ class FakeTable(sql.ModelBase):
raise KeyError
class SqlDecorators(tests.TestCase):
class SqlDecorators(unit.TestCase):
def test_initialization_fail(self):
self.assertRaises(exception.StringLengthExceeded,
@ -863,7 +863,7 @@ class SqlDecorators(tests.TestCase):
self.assertRaises(KeyError, FakeTable().lookup)
class SqlModuleInitialization(tests.TestCase):
class SqlModuleInitialization(unit.TestCase):
@mock.patch.object(sql.core, 'CONF')
@mock.patch.object(options, 'set_defaults')

View File

@ -18,7 +18,7 @@ import mock
from six.moves import zip
from keystone import catalog
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
from keystone.tests.unit import test_backend
@ -28,7 +28,7 @@ BROKEN_WRITE_FUNCTIONALITY_MSG = ("Templated backend doesn't correctly "
"implement write operations")
class TestTemplatedCatalog(tests.TestCase, test_backend.CatalogTests):
class TestTemplatedCatalog(unit.TestCase, test_backend.CatalogTests):
DEFAULT_FIXTURE = {
'RegionOne': {
@ -60,7 +60,7 @@ class TestTemplatedCatalog(tests.TestCase, test_backend.CatalogTests):
self.config_fixture.config(
group='catalog',
driver='templated',
template_file=tests.dirs.tests('default_catalog.templates'))
template_file=unit.dirs.tests('default_catalog.templates'))
def test_get_catalog(self):
catalog_ref = self.catalog_api.get_catalog('foo', 'bar')
@ -161,11 +161,11 @@ class TestTemplatedCatalog(tests.TestCase, test_backend.CatalogTests):
def test_region_crud(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_cache_layer_region_crud(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_region(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@ -189,11 +189,11 @@ class TestTemplatedCatalog(tests.TestCase, test_backend.CatalogTests):
def test_service_crud(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_cache_layer_service_crud(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_service(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)
@ -234,6 +234,6 @@ class TestTemplatedCatalog(tests.TestCase, test_backend.CatalogTests):
endpoints = self.catalog_api.list_endpoints()
self.assertEqual(expected_ids, set(e['id'] for e in endpoints))
@tests.skip_if_cache_disabled('catalog')
@unit.skip_if_cache_disabled('catalog')
def test_invalidate_cache_when_updating_endpoint(self):
self.skipTest(BROKEN_WRITE_FUNCTIONALITY_MSG)

View File

@ -23,7 +23,7 @@ from oslo_config import cfg
from keystone.common import cache
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
CONF = cfg.CONF
@ -76,7 +76,7 @@ class TestProxyValue(object):
self.cached = False
class CacheRegionTest(tests.TestCase):
class CacheRegionTest(unit.TestCase):
def setUp(self):
super(CacheRegionTest, self).setUp()
@ -293,7 +293,7 @@ class CacheRegionTest(tests.TestCase):
"bogus")
class CacheNoopBackendTest(tests.TestCase):
class CacheNoopBackendTest(unit.TestCase):
def setUp(self):
super(CacheNoopBackendTest, self).setUp()

View File

@ -24,7 +24,7 @@ from six.moves import range
from keystone.common.cache.backends import mongo
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
# Mock database structure sample where 'ks_cache' is database and
@ -278,7 +278,7 @@ class MyTransformer(mongo.BaseTransform):
return super(MyTransformer, self).transform_outgoing(son, collection)
class MongoCache(tests.BaseTestCase):
class MongoCache(unit.BaseTestCase):
def setUp(self):
super(MongoCache, self).setUp()
global COLLECTIONS

View File

@ -15,7 +15,7 @@
import uuid
from keystone import catalog
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import database
from keystone.tests.unit import rest
@ -30,7 +30,7 @@ class V2CatalogTestCase(rest.RestfulTestCase):
self.useFixture(database.Database())
self.service_id = uuid.uuid4().hex
self.service = tests.new_service_ref()
self.service = unit.new_service_ref()
self.service['id'] = self.service_id
self.catalog_api.create_service(
self.service_id,
@ -200,7 +200,7 @@ class V2CatalogTestCase(rest.RestfulTestCase):
adminurl=invalid_url)
class TestV2CatalogAPISQL(tests.TestCase):
class TestV2CatalogAPISQL(unit.TestCase):
def setUp(self):
super(TestV2CatalogAPISQL, self).setUp()

View File

@ -22,13 +22,13 @@ from testtools import matchers
from keystone.common import environment
from keystone.common import openssl
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import rest
from keystone import token
SSLDIR = tests.dirs.tmp('ssl')
CONF = tests.CONF
SSLDIR = unit.dirs.tmp('ssl')
CONF = unit.CONF
DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id
@ -219,7 +219,7 @@ class CertSetupTestCase(rest.RestfulTestCase):
self.assertEqual(cert_file1, cert_file2)
class TestExecCommand(tests.TestCase):
class TestExecCommand(unit.TestCase):
@mock.patch.object(environment.subprocess.Popen, 'poll')
def test_running_a_successful_command(self, mock_poll):

View File

@ -23,17 +23,17 @@ from keystone.cmd import cli
from keystone.common import dependency
from keystone.i18n import _
from keystone import resource
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import database
CONF = cfg.CONF
class CliTestCase(tests.SQLDriverOverrides, tests.TestCase):
class CliTestCase(unit.SQLDriverOverrides, unit.TestCase):
def config_files(self):
config_files = super(CliTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def test_token_flush(self):
@ -42,7 +42,7 @@ class CliTestCase(tests.SQLDriverOverrides, tests.TestCase):
cli.TokenFlush.main()
class CliDomainConfigAllTestCase(tests.SQLDriverOverrides, tests.TestCase):
class CliDomainConfigAllTestCase(unit.SQLDriverOverrides, unit.TestCase):
def setUp(self):
self.useFixture(database.Database())
@ -50,7 +50,7 @@ class CliDomainConfigAllTestCase(tests.SQLDriverOverrides, tests.TestCase):
self.load_backends()
self.config_fixture.config(
group='identity',
domain_config_dir=tests.TESTCONF + '/domain_configs_multi_ldap')
domain_config_dir=unit.TESTCONF + '/domain_configs_multi_ldap')
self.domain_count = 3
self.setup_initial_domains()
@ -58,7 +58,7 @@ class CliDomainConfigAllTestCase(tests.SQLDriverOverrides, tests.TestCase):
self.config_fixture.register_cli_opt(cli.command_opt)
self.addCleanup(self.cleanup)
config_files = super(CliDomainConfigAllTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def cleanup(self):

View File

@ -18,31 +18,31 @@ from oslo_config import cfg
from keystone import config
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
CONF = cfg.CONF
class ConfigTestCase(tests.TestCase):
class ConfigTestCase(unit.TestCase):
def config_files(self):
config_files = super(ConfigTestCase, self).config_files()
# Insert the keystone sample as the first config file to be loaded
# since it is used in one of the code paths to determine the paste-ini
# location.
config_files.insert(0, tests.dirs.etc('keystone.conf.sample'))
config_files.insert(0, unit.dirs.etc('keystone.conf.sample'))
return config_files
def test_paste_config(self):
self.assertEqual(tests.dirs.etc('keystone-paste.ini'),
self.assertEqual(unit.dirs.etc('keystone-paste.ini'),
config.find_paste_config())
self.config_fixture.config(group='paste_deploy',
config_file=uuid.uuid4().hex)
self.assertRaises(exception.ConfigFileNotFound,
config.find_paste_config)
self.config_fixture.config(group='paste_deploy', config_file='')
self.assertEqual(tests.dirs.etc('keystone.conf.sample'),
self.assertEqual(unit.dirs.etc('keystone.conf.sample'),
config.find_paste_config())
def test_config_default(self):
@ -50,12 +50,12 @@ class ConfigTestCase(tests.TestCase):
self.assertIs(None, CONF.auth.token)
class DeprecatedTestCase(tests.TestCase):
class DeprecatedTestCase(unit.TestCase):
"""Test using the original (deprecated) name for renamed options."""
def config_files(self):
config_files = super(DeprecatedTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('deprecated.conf'))
config_files.append(unit.dirs.tests_conf('deprecated.conf'))
return config_files
def test_sql(self):
@ -66,12 +66,12 @@ class DeprecatedTestCase(tests.TestCase):
self.assertEqual(54321, CONF.database.idle_timeout)
class DeprecatedOverrideTestCase(tests.TestCase):
class DeprecatedOverrideTestCase(unit.TestCase):
"""Test using the deprecated AND new name for renamed options."""
def config_files(self):
config_files = super(DeprecatedOverrideTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('deprecated_override.conf'))
config_files.append(unit.dirs.tests_conf('deprecated_override.conf'))
return config_files
def test_sql(self):

View File

@ -18,12 +18,12 @@ from keystoneclient.contrib.ec2 import utils as ec2_utils
from keystone.contrib.ec2 import controllers
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
class TestCredentialEc2(tests.TestCase):
class TestCredentialEc2(unit.TestCase):
# TODO(davechen): more testcases for ec2 credential are expected here and
# the file name would be renamed to "test_credential" to correspond with
# "test_v3_credential.py".

View File

@ -16,10 +16,10 @@ import uuid
from keystone.contrib import s3
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
class S3ContribCore(tests.TestCase):
class S3ContribCore(unit.TestCase):
def setUp(self):
super(S3ContribCore, self).setUp()

View File

@ -21,10 +21,10 @@ import six
from keystone.common import wsgi
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
class ExceptionTestCase(tests.BaseTestCase):
class ExceptionTestCase(unit.BaseTestCase):
def assertValidJsonRendering(self, e):
resp = wsgi.render_exception(e)
self.assertEqual(e.code, resp.status_int)

View File

@ -16,14 +16,14 @@
from oslo_config import cfg
from keystone.common import environment
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import appserver
CONF = cfg.CONF
class IPv6TestCase(tests.TestCase):
class IPv6TestCase(unit.TestCase):
def setUp(self):
self.skip_if_no_ipv6()

View File

@ -26,7 +26,7 @@ from keystone.common.kvs.backends import inmemdb
from keystone.common.kvs.backends import memcached
from keystone.common.kvs import core
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
NO_VALUE = api.NO_VALUE
@ -147,7 +147,7 @@ class TestMemcacheDriver(api.CacheBackend):
self.client.set_multi(mapping, **self.set_arguments)
class KVSTest(tests.TestCase):
class KVSTest(unit.TestCase):
def setUp(self):
super(KVSTest, self).setUp()
self.key_foo = 'foo_' + uuid.uuid4().hex
@ -569,7 +569,7 @@ class KVSTest(tests.TestCase):
key=test_key)
class TestMemcachedBackend(tests.TestCase):
class TestMemcachedBackend(unit.TestCase):
@mock.patch('keystone.common.kvs.backends.memcached._', six.text_type)
def test_invalid_backend_fails_initialization(self):

View File

@ -21,7 +21,7 @@ from six.moves import range
from keystone import exception
from keystone.identity.backends import ldap as identity_ldap
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_backend_ldap
@ -78,7 +78,7 @@ class LiveLDAPIdentity(test_backend_ldap.LDAPIdentity):
def config_files(self):
config_files = super(LiveLDAPIdentity, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_liveldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_liveldap.conf'))
return config_files
def test_build_tree(self):

View File

@ -19,7 +19,7 @@ from oslo_config import cfg
from keystone.common.ldap import core as ldap_core
from keystone.identity.backends import ldap
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import fakeldap
from keystone.tests.unit import test_backend_ldap_pool
from keystone.tests.unit import test_ldap_livetest
@ -44,8 +44,7 @@ class LiveLDAPPoolIdentity(test_backend_ldap_pool.LdapPoolCommonTestMixin,
def config_files(self):
config_files = super(LiveLDAPPoolIdentity, self).config_files()
config_files.append(tests.dirs.
tests_conf('backend_pool_liveldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_pool_liveldap.conf'))
return config_files
def test_assert_connector_used_not_fake_ldap_pool(self):

View File

@ -18,7 +18,7 @@ from oslo_config import cfg
from keystone import exception
from keystone import identity
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_ldap_livetest
@ -40,7 +40,7 @@ class LiveTLSLDAPIdentity(test_ldap_livetest.LiveLDAPIdentity):
def config_files(self):
config_files = super(LiveTLSLDAPIdentity, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_tls_liveldap.conf'))
config_files.append(unit.dirs.tests_conf('backend_tls_liveldap.conf'))
return config_files
def test_tls_certfile_demand_option(self):

View File

@ -23,7 +23,7 @@ from keystone.common import tokenless_auth
from keystone.contrib.federation import constants as federation_constants
from keystone import exception
from keystone import middleware
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import mapping_fixtures
from keystone.tests.unit import test_backend_sql
@ -49,7 +49,7 @@ def make_response(**kwargs):
return webob.Response(body)
class TokenAuthMiddlewareTest(tests.TestCase):
class TokenAuthMiddlewareTest(unit.TestCase):
def test_request(self):
req = make_request()
req.headers[middleware.AUTH_TOKEN_HEADER] = 'MAGIC'
@ -58,7 +58,7 @@ class TokenAuthMiddlewareTest(tests.TestCase):
self.assertEqual('MAGIC', context['token_id'])
class AdminTokenAuthMiddlewareTest(tests.TestCase):
class AdminTokenAuthMiddlewareTest(unit.TestCase):
def test_request_admin(self):
req = make_request()
req.headers[middleware.AUTH_TOKEN_HEADER] = CONF.admin_token
@ -74,7 +74,7 @@ class AdminTokenAuthMiddlewareTest(tests.TestCase):
self.assertFalse(context['is_admin'])
class PostParamsMiddlewareTest(tests.TestCase):
class PostParamsMiddlewareTest(unit.TestCase):
def test_request_with_params(self):
req = make_request(body="arg1=one", method='POST')
middleware.PostParamsMiddleware(None).process_request(req)
@ -82,7 +82,7 @@ class PostParamsMiddlewareTest(tests.TestCase):
self.assertEqual({"arg1": "one"}, params)
class JsonBodyMiddlewareTest(tests.TestCase):
class JsonBodyMiddlewareTest(unit.TestCase):
def test_request_with_params(self):
req = make_request(body='{"arg1": "one", "arg2": ["a"]}',
content_type='application/json',

View File

@ -16,10 +16,10 @@ import os
import webtest
from keystone.tests import unit as tests
from keystone.tests import unit
class TestNoAdminTokenAuth(tests.TestCase):
class TestNoAdminTokenAuth(unit.TestCase):
def setUp(self):
super(TestNoAdminTokenAuth, self).setUp()
self.load_backends()
@ -27,7 +27,7 @@ class TestNoAdminTokenAuth(tests.TestCase):
self._generate_paste_config()
self.admin_app = webtest.TestApp(
self.loadapp(tests.dirs.tmp('no_admin_token_auth'), name='admin'),
self.loadapp(unit.dirs.tmp('no_admin_token_auth'), name='admin'),
extra_environ=dict(REMOTE_ADDR='127.0.0.1'))
self.addCleanup(setattr, self, 'admin_app', None)
@ -35,12 +35,12 @@ class TestNoAdminTokenAuth(tests.TestCase):
# Generate a file, based on keystone-paste.ini, that doesn't include
# admin_token_auth in the pipeline
with open(tests.dirs.etc('keystone-paste.ini'), 'r') as f:
with open(unit.dirs.etc('keystone-paste.ini'), 'r') as f:
contents = f.read()
new_contents = contents.replace(' admin_token_auth ', ' ')
filename = tests.dirs.tmp('no_admin_token_auth-paste.ini')
filename = unit.dirs.tmp('no_admin_token_auth-paste.ini')
with open(filename, 'w') as f:
f.write(new_contents)
self.addCleanup(os.remove, filename)

View File

@ -24,11 +24,11 @@ from testtools import matchers
from keystone import exception
from keystone.policy.backends import rules
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import temporaryfile
class BasePolicyTestCase(tests.TestCase):
class BasePolicyTestCase(unit.TestCase):
def setUp(self):
super(BasePolicyTestCase, self).setUp()
rules.reset()
@ -214,15 +214,15 @@ class DefaultPolicyTestCase(BasePolicyTestCase):
self.credentials, "example:noexist", {})
class PolicyJsonTestCase(tests.TestCase):
class PolicyJsonTestCase(unit.TestCase):
def _load_entries(self, filename):
return set(json.load(open(filename)))
def test_json_examples_have_matching_entries(self):
policy_keys = self._load_entries(tests.dirs.etc('policy.json'))
policy_keys = self._load_entries(unit.dirs.etc('policy.json'))
cloud_policy_keys = self._load_entries(
tests.dirs.etc('policy.v3cloudsample.json'))
unit.dirs.etc('policy.v3cloudsample.json'))
policy_extra_keys = ['admin_or_token_subject',
'service_admin_or_token_subject',
@ -236,7 +236,7 @@ class PolicyJsonTestCase(tests.TestCase):
# All the targets in the sample policy file must be documented in
# doc/source/policy_mapping.rst.
policy_keys = self._load_entries(tests.dirs.etc('policy.json'))
policy_keys = self._load_entries(unit.dirs.etc('policy.json'))
# These keys are in the policy.json but aren't targets.
policy_rule_keys = [
@ -249,7 +249,7 @@ class PolicyJsonTestCase(tests.TestCase):
# targets.
doc_path = os.path.join(
tests.ROOTDIR, 'doc', 'source', 'policy_mapping.rst')
unit.ROOTDIR, 'doc', 'source', 'policy_mapping.rst')
with open(doc_path) as doc_file:
for line in doc_file:
if line.startswith('Target'):

View File

@ -22,7 +22,7 @@ from testtools import matchers
from keystone.common import utils
from keystone.contrib.revoke import model
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_backend_sql
from keystone.token import provider
@ -191,7 +191,7 @@ class SqlRevokeTests(test_backend_sql.SqlTests, RevokeTests):
revoke_by_id=False)
class KvsRevokeTests(tests.TestCase, RevokeTests):
class KvsRevokeTests(unit.TestCase, RevokeTests):
def config_overrides(self):
super(KvsRevokeTests, self).config_overrides()
self.config_fixture.config(group='revoke', driver='kvs')
@ -205,7 +205,7 @@ class KvsRevokeTests(tests.TestCase, RevokeTests):
self.load_backends()
class RevokeTreeTests(tests.TestCase):
class RevokeTreeTests(unit.TestCase):
def setUp(self):
super(RevokeTreeTests, self).setUp()
self.events = []

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_sql_migrate_extensions
from keystone.tests.unit import test_sql_upgrade
@ -24,7 +24,7 @@ class PostgresqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def config_files(self):
files = super(PostgresqlMigrateTests, self).config_files()
files.append(tests.dirs.tests_conf("backend_postgresql.conf"))
files.append(unit.dirs.tests_conf("backend_postgresql.conf"))
return files
@ -35,7 +35,7 @@ class MysqlMigrateTests(test_sql_upgrade.SqlUpgradeTests):
def config_files(self):
files = super(MysqlMigrateTests, self).config_files()
files.append(tests.dirs.tests_conf("backend_mysql.conf"))
files.append(unit.dirs.tests_conf("backend_mysql.conf"))
return files
@ -47,7 +47,7 @@ class PostgresqlRevokeExtensionsTests(
def config_files(self):
files = super(PostgresqlRevokeExtensionsTests, self).config_files()
files.append(tests.dirs.tests_conf("backend_postgresql.conf"))
files.append(unit.dirs.tests_conf("backend_postgresql.conf"))
return files
@ -58,7 +58,7 @@ class MysqlRevokeExtensionsTests(test_sql_migrate_extensions.RevokeExtension):
def config_files(self):
files = super(MysqlRevokeExtensionsTests, self).config_files()
files.append(tests.dirs.tests_conf("backend_mysql.conf"))
files.append(unit.dirs.tests_conf("backend_mysql.conf"))
return files
@ -69,5 +69,5 @@ class Db2MigrateTests(test_sql_upgrade.SqlUpgradeTests):
def config_files(self):
files = super(Db2MigrateTests, self).config_files()
files.append(tests.dirs.tests_conf("backend_db2.conf"))
files.append(unit.dirs.tests_conf("backend_db2.conf"))
return files

View File

@ -48,7 +48,7 @@ from keystone.common.sql import migration_helpers
from keystone.contrib import federation
from keystone.contrib import revoke
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
@ -124,14 +124,14 @@ EXTENSIONS = {'federation': federation,
'revoke': revoke}
class SqlMigrateBase(tests.SQLDriverOverrides, tests.TestCase):
class SqlMigrateBase(unit.SQLDriverOverrides, unit.TestCase):
def initialize_sql(self):
self.metadata = sqlalchemy.MetaData()
self.metadata.bind = self.engine
def config_files(self):
config_files = super(SqlMigrateBase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def repo_package(self):
@ -141,15 +141,15 @@ class SqlMigrateBase(tests.SQLDriverOverrides, tests.TestCase):
super(SqlMigrateBase, self).setUp()
database.initialize_sql_session()
conn_str = CONF.database.connection
if (conn_str != tests.IN_MEM_DB_CONN_STRING and
if (conn_str != unit.IN_MEM_DB_CONN_STRING and
conn_str.startswith('sqlite') and
conn_str[10:] == tests.DEFAULT_TEST_DB_FILE):
conn_str[10:] == unit.DEFAULT_TEST_DB_FILE):
# Override the default with a DB that is specific to the migration
# tests only if the DB Connection string is the same as the global
# default. This is required so that no conflicts occur due to the
# global default DB already being under migrate control. This is
# only needed if the DB is not-in-memory
db_file = tests.dirs.tmp('keystone_migrate_test.db')
db_file = unit.dirs.tmp('keystone_migrate_test.db')
self.config_fixture.config(
group='database',
connection='sqlite:///%s' % db_file)

View File

@ -19,21 +19,21 @@ import ssl
from oslo_config import cfg
from keystone.common import environment
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import appserver
CONF = cfg.CONF
CERTDIR = tests.dirs.root('examples', 'pki', 'certs')
KEYDIR = tests.dirs.root('examples', 'pki', 'private')
CERTDIR = unit.dirs.root('examples', 'pki', 'certs')
KEYDIR = unit.dirs.root('examples', 'pki', 'private')
CERT = os.path.join(CERTDIR, 'ssl_cert.pem')
KEY = os.path.join(KEYDIR, 'ssl_key.pem')
CA = os.path.join(CERTDIR, 'cacert.pem')
CLIENT = os.path.join(CERTDIR, 'middleware.pem')
class SSLTestCase(tests.TestCase):
class SSLTestCase(unit.TestCase):
def setUp(self):
super(SSLTestCase, self).setUp()
raise self.skipTest('SSL Version and Ciphers cannot be configured '

View File

@ -18,7 +18,7 @@ import uuid
from keystone.common import wsgi
from keystone import exception
from keystone.models import token_model
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_token_provider
@ -26,7 +26,7 @@ KERBEROS_BIND = 'USER@REALM'
ANY = 'any'
class BindTest(tests.TestCase):
class BindTest(unit.TestCase):
"""Test binding tokens to a Principal.
Even though everything in this file references kerberos the same concepts

View File

@ -20,7 +20,7 @@ from oslo_utils import timeutils
from keystone.common import dependency
from keystone.common import utils
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import database
from keystone import token
from keystone.token.providers import fernet
@ -712,7 +712,7 @@ SAMPLE_MALFORMED_TOKEN = {
}
class TestTokenProvider(tests.TestCase):
class TestTokenProvider(unit.TestCase):
def setUp(self):
super(TestTokenProvider, self).setUp()
self.useFixture(database.Database())
@ -817,7 +817,7 @@ class PKIProviderTests(object):
token_data)
class TestPKIProviderWithEventlet(PKIProviderTests, tests.TestCase):
class TestPKIProviderWithEventlet(PKIProviderTests, unit.TestCase):
def setUp(self):
# force keystoneclient.common.cms to use eventlet's subprocess
@ -827,7 +827,7 @@ class TestPKIProviderWithEventlet(PKIProviderTests, tests.TestCase):
super(TestPKIProviderWithEventlet, self).setUp()
class TestPKIProviderWithStdlib(PKIProviderTests, tests.TestCase):
class TestPKIProviderWithStdlib(PKIProviderTests, unit.TestCase):
def setUp(self):
# force keystoneclient.common.cms to use the stdlib subprocess

View File

@ -15,7 +15,7 @@
import webob
from keystone import middleware
from keystone.tests import unit as tests
from keystone.tests import unit
class FakeApp(object):
@ -26,7 +26,7 @@ class FakeApp(object):
return resp(env, start_response)
class UrlMiddlewareTest(tests.TestCase):
class UrlMiddlewareTest(unit.TestCase):
def setUp(self):
self.middleware = middleware.NormalizingFilter(FakeApp())
self.response_status = None

View File

@ -18,7 +18,7 @@ import uuid
from keystone.assignment import controllers as assignment_controllers
from keystone import exception
from keystone.resource import controllers as resource_controllers
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import database
@ -26,7 +26,7 @@ from keystone.tests.unit.ksfixtures import database
_ADMIN_CONTEXT = {'is_admin': True, 'query_string': {}}
class TenantTestCase(tests.TestCase):
class TenantTestCase(unit.TestCase):
"""Tests for the V2 Tenant controller.
These tests exercise :class:`keystone.assignment.controllers.Tenant`.

View File

@ -25,7 +25,7 @@ from oslo_utils import timeutils
from six.moves import range
import webob
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import default_fixtures
from keystone.tests.unit.ksfixtures import appserver
from keystone.tests.unit.ksfixtures import database
@ -35,11 +35,11 @@ CONF = cfg.CONF
DEFAULT_DOMAIN_ID = CONF.identity.default_domain_id
class ClientDrivenTestCase(tests.TestCase):
class ClientDrivenTestCase(unit.TestCase):
def config_files(self):
config_files = super(ClientDrivenTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def setUp(self):

View File

@ -26,14 +26,14 @@ from keystone.common import cache
from keystone import exception
from keystone import middleware
from keystone.policy.backends import rules
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import rest
CONF = cfg.CONF
DEFAULT_DOMAIN_ID = 'default'
TIME_FORMAT = tests.TIME_FORMAT
TIME_FORMAT = unit.TIME_FORMAT
class AuthTestMixin(object):
@ -115,11 +115,11 @@ class AuthTestMixin(object):
return {'auth': auth_data}
class RestfulTestCase(tests.SQLDriverOverrides, rest.RestfulTestCase,
class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
AuthTestMixin):
def config_files(self):
config_files = super(RestfulTestCase, self).config_files()
config_files.append(tests.dirs.tests_conf('backend_sql.conf'))
config_files.append(unit.dirs.tests_conf('backend_sql.conf'))
return config_files
def get_extensions(self):
@ -131,7 +131,7 @@ class RestfulTestCase(tests.SQLDriverOverrides, rest.RestfulTestCase,
def generate_paste_config(self):
new_paste_file = None
try:
new_paste_file = tests.generate_paste_config(self.EXTENSION_TO_ADD)
new_paste_file = unit.generate_paste_config(self.EXTENSION_TO_ADD)
except AttributeError:
# no need to report this error here, as most tests will not have
# EXTENSION_TO_ADD defined.
@ -141,7 +141,7 @@ class RestfulTestCase(tests.SQLDriverOverrides, rest.RestfulTestCase,
def remove_generated_paste_config(self):
try:
tests.remove_generated_paste_config(self.EXTENSION_TO_ADD)
unit.remove_generated_paste_config(self.EXTENSION_TO_ADD)
except AttributeError:
pass
@ -175,7 +175,7 @@ class RestfulTestCase(tests.SQLDriverOverrides, rest.RestfulTestCase,
self.load_sample_data()
def _populate_default_domain(self):
if CONF.database.connection == tests.IN_MEM_DB_CONN_STRING:
if CONF.database.connection == unit.IN_MEM_DB_CONN_STRING:
# NOTE(morganfainberg): If an in-memory db is being used, be sure
# to populate the default domain, this is typically done by
# a migration, but the in-mem db uses model definitions to create
@ -265,47 +265,47 @@ class RestfulTestCase(tests.SQLDriverOverrides, rest.RestfulTestCase,
def new_ref(self):
"""Populates a ref with attributes common to some API entities."""
return tests.new_ref()
return unit.new_ref()
def new_region_ref(self):
return tests.new_region_ref()
return unit.new_region_ref()
def new_service_ref(self):
return tests.new_service_ref()
return unit.new_service_ref()
def new_endpoint_ref(self, service_id, interface='public', **kwargs):
return tests.new_endpoint_ref(
return unit.new_endpoint_ref(
service_id, interface=interface, default_region_id=self.region_id,
**kwargs)
def new_domain_ref(self):
return tests.new_domain_ref()
return unit.new_domain_ref()
def new_project_ref(self, domain_id=None, parent_id=None, is_domain=False):
return tests.new_project_ref(domain_id=domain_id, parent_id=parent_id,
is_domain=is_domain)
return unit.new_project_ref(domain_id=domain_id, parent_id=parent_id,
is_domain=is_domain)
def new_user_ref(self, domain_id, project_id=None):
return tests.new_user_ref(domain_id, project_id=project_id)
return unit.new_user_ref(domain_id, project_id=project_id)
def new_group_ref(self, domain_id):
return tests.new_group_ref(domain_id)
return unit.new_group_ref(domain_id)
def new_credential_ref(self, user_id, project_id=None, cred_type=None):
return tests.new_credential_ref(user_id, project_id=project_id,
cred_type=cred_type)
return unit.new_credential_ref(user_id, project_id=project_id,
cred_type=cred_type)
def new_role_ref(self):
return tests.new_role_ref()
return unit.new_role_ref()
def new_policy_ref(self):
return tests.new_policy_ref()
return unit.new_policy_ref()
def new_trust_ref(self, trustor_user_id, trustee_user_id, project_id=None,
impersonation=None, expires=None, role_ids=None,
role_names=None, remaining_uses=None,
allow_redelegation=False):
return tests.new_trust_ref(
return unit.new_trust_ref(
trustor_user_id, trustee_user_id, project_id=project_id,
impersonation=impersonation, expires=expires, role_ids=role_ids,
role_names=role_names, remaining_uses=remaining_uses,

View File

@ -18,7 +18,7 @@ from six.moves import range
from keystone.common import controller
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_v3
from keystone.tests.unit import utils
@ -3075,7 +3075,7 @@ class AssignmentInheritanceDisabledTestCase(test_v3.RestfulTestCase):
self.delete(member_url, expected_status=404)
class AssignmentV3toV2MethodsTestCase(tests.TestCase):
class AssignmentV3toV2MethodsTestCase(unit.TestCase):
"""Test domain V3 to V2 conversion methods."""
def _setup_initial_projects(self):
self.project_id = uuid.uuid4().hex

View File

@ -30,7 +30,7 @@ from keystone import auth
from keystone.common import utils
from keystone import exception
from keystone.policy.backends import rules
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import ksfixtures
from keystone.tests.unit import test_v3
@ -637,7 +637,7 @@ class TestTokenRevokeSelfAndAdmin(test_v3.RestfulTestCase):
super(TestTokenRevokeSelfAndAdmin, self).config_overrides()
self.config_fixture.config(
group='oslo_policy',
policy_file=tests.dirs.etc('policy.v3cloudsample.json'))
policy_file=unit.dirs.etc('policy.v3cloudsample.json'))
def test_user_revokes_own_token(self):
user_token = self.get_requested_token(
@ -4001,7 +4001,7 @@ class TestAPIProtectionWithoutAuthContextMiddleware(test_v3.RestfulTestCase):
self.assertEqual(200, r.status_code)
class TestAuthContext(tests.TestCase):
class TestAuthContext(unit.TestCase):
def setUp(self):
super(TestAuthContext, self).setUp()
self.auth_context = auth.controllers.AuthContext()

View File

@ -18,7 +18,7 @@ import uuid
from testtools import matchers
from keystone import catalog
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import database
from keystone.tests.unit import test_v3
@ -801,7 +801,7 @@ class CatalogTestCase(test_v3.RestfulTestCase):
expected_status=400)
class TestCatalogAPISQL(tests.TestCase):
class TestCatalogAPISQL(unit.TestCase):
"""Tests for the catalog Manager against the SQL backend.
"""
@ -909,7 +909,7 @@ class TestCatalogAPISQL(tests.TestCase):
# TODO(dstanek): this needs refactoring with the test above, but we are in a
# crunch so that will happen in a future patch.
class TestCatalogAPISQLRegions(tests.TestCase):
class TestCatalogAPISQLRegions(unit.TestCase):
"""Tests for the catalog Manager against the SQL backend.
"""

View File

@ -20,10 +20,10 @@ from testtools import matchers
from keystone.common import controller
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
class V3ControllerTestCase(tests.TestCase):
class V3ControllerTestCase(unit.TestCase):
"""Tests for the V3Controller class."""
def setUp(self):
super(V3ControllerTestCase, self).setUp()

View File

@ -21,7 +21,7 @@ from testtools import matchers
from keystone.common import controller
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import test_v3
@ -469,7 +469,7 @@ class IdentityTestCase(test_v3.RestfulTestCase):
self.assertNotIn(new_password, log_fix.output)
class IdentityV3toV2MethodsTestCase(tests.TestCase):
class IdentityV3toV2MethodsTestCase(unit.TestCase):
"""Test users V3 to V2 conversion methods."""
def setUp(self):

View File

@ -20,7 +20,7 @@ from oslo_serialization import jsonutils
from keystone import exception
from keystone.policy.backends import rules
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit.ksfixtures import temporaryfile
from keystone.tests.unit import test_v3
@ -607,7 +607,7 @@ class IdentityTestv3CloudPolicySample(test_v3.RestfulTestCase,
rules.reset()
self.config_fixture.config(
group='oslo_policy',
policy_file=tests.dirs.etc('policy.v3cloudsample.json'))
policy_file=unit.dirs.etc('policy.v3cloudsample.json'))
def load_sample_data(self):
# Start by creating a couple of domains
@ -986,7 +986,7 @@ class IdentityTestv3CloudPolicySample(test_v3.RestfulTestCase,
self.assertRoleAssignmentInListResponse(r, project_admin_entity)
self.assertRoleAssignmentInListResponse(r, project_user_entity)
@tests.utils.wip('waiting on bug #1437407')
@unit.utils.wip('waiting on bug #1437407')
def test_domain_admin_list_assignments_of_project(self):
self.auth = self.build_authentication_request(
user_id=self.domain_admin_user['id'],

View File

@ -24,7 +24,7 @@ from testtools import matchers as tt_matchers
from keystone.common import json_home
from keystone import controllers
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import utils
@ -639,7 +639,7 @@ class _VersionsEqual(tt_matchers.MatchesListwise):
])
class VersionTestCase(tests.TestCase):
class VersionTestCase(unit.TestCase):
def setUp(self):
super(VersionTestCase, self).setUp()
self.load_backends()
@ -664,7 +664,7 @@ class VersionTestCase(tests.TestCase):
link['href'] = port
def test_public_versions(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
resp = client.get('/')
self.assertEqual(300, resp.status_int)
data = jsonutils.loads(resp.body)
@ -681,7 +681,7 @@ class VersionTestCase(tests.TestCase):
self.assertThat(data, _VersionsEqual(expected))
def test_admin_versions(self):
client = tests.TestClient(self.admin_app)
client = unit.TestClient(self.admin_app)
resp = client.get('/')
self.assertEqual(300, resp.status_int)
data = jsonutils.loads(resp.body)
@ -701,7 +701,7 @@ class VersionTestCase(tests.TestCase):
self.config_fixture.config(public_endpoint=None, admin_endpoint=None)
for app in (self.public_app, self.admin_app):
client = tests.TestClient(app)
client = unit.TestClient(app)
resp = client.get('/')
self.assertEqual(300, resp.status_int)
data = jsonutils.loads(resp.body)
@ -717,7 +717,7 @@ class VersionTestCase(tests.TestCase):
self.assertThat(data, _VersionsEqual(expected))
def test_public_version_v2(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
resp = client.get('/v2.0/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -728,7 +728,7 @@ class VersionTestCase(tests.TestCase):
self.assertEqual(expected, data)
def test_admin_version_v2(self):
client = tests.TestClient(self.admin_app)
client = unit.TestClient(self.admin_app)
resp = client.get('/v2.0/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -741,7 +741,7 @@ class VersionTestCase(tests.TestCase):
def test_use_site_url_if_endpoint_unset_v2(self):
self.config_fixture.config(public_endpoint=None, admin_endpoint=None)
for app in (self.public_app, self.admin_app):
client = tests.TestClient(app)
client = unit.TestClient(app)
resp = client.get('/v2.0/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -750,7 +750,7 @@ class VersionTestCase(tests.TestCase):
self.assertEqual(data, expected)
def test_public_version_v3(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
resp = client.get('/v3/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -762,7 +762,7 @@ class VersionTestCase(tests.TestCase):
@utils.wip('waiting on bug #1381961')
def test_admin_version_v3(self):
client = tests.TestClient(self.admin_app)
client = unit.TestClient(self.admin_app)
resp = client.get('/v3/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -775,7 +775,7 @@ class VersionTestCase(tests.TestCase):
def test_use_site_url_if_endpoint_unset_v3(self):
self.config_fixture.config(public_endpoint=None, admin_endpoint=None)
for app in (self.public_app, self.admin_app):
client = tests.TestClient(app)
client = unit.TestClient(app)
resp = client.get('/v3/')
self.assertEqual(200, resp.status_int)
data = jsonutils.loads(resp.body)
@ -785,7 +785,7 @@ class VersionTestCase(tests.TestCase):
@mock.patch.object(controllers, '_VERSIONS', ['v3'])
def test_v2_disabled(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
# request to /v2.0 should fail
resp = client.get('/v2.0/')
self.assertEqual(404, resp.status_int)
@ -818,7 +818,7 @@ class VersionTestCase(tests.TestCase):
@mock.patch.object(controllers, '_VERSIONS', ['v2.0'])
def test_v3_disabled(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
# request to /v3 should fail
resp = client.get('/v3/')
self.assertEqual(404, resp.status_int)
@ -850,7 +850,7 @@ class VersionTestCase(tests.TestCase):
self.assertEqual(v2_only_response, data)
def _test_json_home(self, path, exp_json_home_data):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
resp = client.get(path, headers={'Accept': 'application/json-home'})
self.assertThat(resp.status, tt_matchers.Equals('200 OK'))
@ -883,7 +883,7 @@ class VersionTestCase(tests.TestCase):
# Accept headers with multiple types and qvalues are handled.
def make_request(accept_types=None):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
headers = None
if accept_types:
headers = {'Accept': accept_types}
@ -933,7 +933,7 @@ class VersionTestCase(tests.TestCase):
self.assertIsNone(extensions_property)
class VersionSingleAppTestCase(tests.TestCase):
class VersionSingleAppTestCase(unit.TestCase):
"""Tests running with a single application loaded.
These are important because when Keystone is running in Apache httpd
@ -969,7 +969,7 @@ class VersionSingleAppTestCase(tests.TestCase):
else:
return CONF.eventlet_server.public_port
app = self.loadapp('keystone', app_name)
client = tests.TestClient(app)
client = unit.TestClient(app)
resp = client.get('/')
self.assertEqual(300, resp.status_int)
data = jsonutils.loads(resp.body)
@ -990,7 +990,7 @@ class VersionSingleAppTestCase(tests.TestCase):
self._test_version('admin')
class VersionInheritEnabledTestCase(tests.TestCase):
class VersionInheritEnabledTestCase(unit.TestCase):
def setUp(self):
super(VersionInheritEnabledTestCase, self).setUp()
self.load_backends()
@ -1015,7 +1015,7 @@ class VersionInheritEnabledTestCase(tests.TestCase):
# If the request is /v3 and the Accept header is application/json-home
# then the server responds with a JSON Home document.
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
resp = client.get('/v3/', headers={'Accept': 'application/json-home'})
self.assertThat(resp.status, tt_matchers.Equals('200 OK'))
@ -1029,7 +1029,7 @@ class VersionInheritEnabledTestCase(tests.TestCase):
tt_matchers.Equals(exp_json_home_data))
class VersionBehindSslTestCase(tests.TestCase):
class VersionBehindSslTestCase(unit.TestCase):
def setUp(self):
super(VersionBehindSslTestCase, self).setUp()
self.load_backends()
@ -1055,7 +1055,7 @@ class VersionBehindSslTestCase(tests.TestCase):
return expected
def test_versions_without_headers(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
host_name = 'host-%d' % random.randint(10, 30)
host_port = random.randint(10000, 30000)
host = 'http://%s:%s/' % (host_name, host_port)
@ -1066,7 +1066,7 @@ class VersionBehindSslTestCase(tests.TestCase):
self.assertThat(data, _VersionsEqual(expected))
def test_versions_with_header(self):
client = tests.TestClient(self.public_app)
client = unit.TestClient(self.public_app)
host_name = 'host-%d' % random.randint(10, 30)
host_port = random.randint(10000, 30000)
resp = client.get('http://%s:%s/' % (host_name, host_port),

View File

@ -29,7 +29,7 @@ import webob
from keystone.common import environment
from keystone.common import wsgi
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
class FakeApp(wsgi.Application):
@ -52,7 +52,7 @@ class FakeAttributeCheckerApp(wsgi.Application):
self._require_attributes(ref, attr)
class RouterTest(tests.TestCase):
class RouterTest(unit.TestCase):
def setUp(self):
self.router = wsgi.RoutersBase()
super(RouterTest, self).setUp()
@ -68,7 +68,7 @@ class RouterTest(tests.TestCase):
status=uuid.uuid4().hex)
class BaseWSGITest(tests.TestCase):
class BaseWSGITest(unit.TestCase):
def setUp(self):
self.app = FakeApp()
super(BaseWSGITest, self).setUp()
@ -311,7 +311,7 @@ class MiddlewareTest(BaseWSGITest):
self.assertEqual("test", app.kwargs["testkey"])
class LocalizedResponseTest(tests.TestCase):
class LocalizedResponseTest(unit.TestCase):
def test_request_match_default(self):
# The default language if no Accept-Language is provided is None
req = webob.Request.blank('/')
@ -409,7 +409,7 @@ class LocalizedResponseTest(tests.TestCase):
self.assertThat(xlation_mock.called, matchers.Equals(True))
class ServerTest(tests.TestCase):
class ServerTest(unit.TestCase):
def setUp(self):
super(ServerTest, self).setUp()

View File

@ -19,28 +19,28 @@ from oslo_log import log
from sqlalchemy import exc
from testtools import matchers
from keystone.tests import unit as tests
from keystone.tests import unit
LOG = log.getLogger(__name__)
class BaseTestTestCase(tests.BaseTestCase):
class BaseTestTestCase(unit.BaseTestCase):
def test_unexpected_exit(self):
# if a test calls sys.exit it raises rather than exiting.
self.assertThat(lambda: sys.exit(),
matchers.raises(tests.UnexpectedExit))
matchers.raises(unit.UnexpectedExit))
class TestTestCase(tests.TestCase):
class TestTestCase(unit.TestCase):
def test_bad_log(self):
# If the arguments are invalid for the string in a log it raises an
# exception during testing.
self.assertThat(
lambda: LOG.warn('String %(p1)s %(p2)s', {'p1': 'something'}),
matchers.raises(tests.BadLog))
matchers.raises(unit.BadLog))
def test_sa_warning(self):
self.assertThat(

View File

@ -20,7 +20,7 @@ from oslo_utils import timeutils
from keystone.common import config
from keystone.common import utils
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.tests.unit import ksfixtures
from keystone.token import provider
from keystone.token.providers import fernet
@ -31,7 +31,7 @@ from keystone.token.providers.fernet import utils as fernet_utils
CONF = config.CONF
class TestFernetTokenProvider(tests.TestCase):
class TestFernetTokenProvider(unit.TestCase):
def setUp(self):
super(TestFernetTokenProvider, self).setUp()
self.useFixture(ksfixtures.KeyRepository(self.config_fixture))
@ -56,7 +56,7 @@ class TestFernetTokenProvider(tests.TestCase):
uuid.uuid4().hex)
class TestPayloads(tests.TestCase):
class TestPayloads(unit.TestCase):
def test_uuid_hex_to_byte_conversions(self):
payload_cls = token_formatters.BasePayload
@ -387,7 +387,7 @@ class TestPayloads(tests.TestCase):
self.assertDictEqual(exp_federated_info, federated_info)
class TestFernetKeyRotation(tests.TestCase):
class TestFernetKeyRotation(unit.TestCase):
def setUp(self):
super(TestFernetKeyRotation, self).setUp()
@ -512,7 +512,7 @@ class TestFernetKeyRotation(tests.TestCase):
self.assertEqual(3, keys)
class TestLoadKeys(tests.TestCase):
class TestLoadKeys(unit.TestCase):
def test_non_numeric_files(self):
self.useFixture(ksfixtures.KeyRepository(self.config_fixture))
evil_file = os.path.join(CONF.fernet_tokens.key_repository, '~1')

View File

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.token.providers import pki
class TestPkiTokenProvider(tests.TestCase):
class TestPkiTokenProvider(unit.TestCase):
def setUp(self):
super(TestPkiTokenProvider, self).setUp()
self.provider = pki.Provider()

View File

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.token.providers import pkiz
class TestPkizTokenProvider(tests.TestCase):
class TestPkizTokenProvider(unit.TestCase):
def setUp(self):
super(TestPkizTokenProvider, self).setUp()
self.provider = pkiz.Provider()

View File

@ -16,11 +16,11 @@ import uuid
from testtools import matchers
from keystone import exception
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.token.providers import common
class TestTokenDataHelper(tests.TestCase):
class TestTokenDataHelper(unit.TestCase):
def setUp(self):
super(TestTokenDataHelper, self).setUp()
self.load_backends()

View File

@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from keystone.tests import unit as tests
from keystone.tests import unit
from keystone.token.providers import uuid
class TestUuidTokenProvider(tests.TestCase):
class TestUuidTokenProvider(unit.TestCase):
def setUp(self):
super(TestUuidTokenProvider, self).setUp()
self.provider = uuid.Provider()