diff options
author | asteroide <thomas.duval@orange.com> | 2015-09-24 16:27:16 +0200 |
---|---|---|
committer | asteroide <thomas.duval@orange.com> | 2015-09-24 16:27:16 +0200 |
commit | 92d11d139e9f76d4fd76859aea78643fc32ef36b (patch) | |
tree | bd5a2e7b50853498074ab55bdaee4452c460010b /keystone-moon/keystone/tests/unit/common | |
parent | 49325d99acfadaadfad99c596c4ada6b5ec849de (diff) |
Update Keystone code from repository.
Change-Id: Ib3d0a06b10902fcc6d520f58e85aa617bc326d00
Diffstat (limited to 'keystone-moon/keystone/tests/unit/common')
8 files changed, 64 insertions, 25 deletions
diff --git a/keystone-moon/keystone/tests/unit/common/test_base64utils.py b/keystone-moon/keystone/tests/unit/common/test_base64utils.py index b0b75578..355a2e03 100644 --- a/keystone-moon/keystone/tests/unit/common/test_base64utils.py +++ b/keystone-moon/keystone/tests/unit/common/test_base64utils.py @@ -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' diff --git a/keystone-moon/keystone/tests/unit/common/test_injection.py b/keystone-moon/keystone/tests/unit/common/test_injection.py index b4c23a84..9a5d1e7d 100644 --- a/keystone-moon/keystone/tests/unit/common/test_injection.py +++ b/keystone-moon/keystone/tests/unit/common/test_injection.py @@ -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() diff --git a/keystone-moon/keystone/tests/unit/common/test_json_home.py b/keystone-moon/keystone/tests/unit/common/test_json_home.py index fb7f8448..94e2d138 100644 --- a/keystone-moon/keystone/tests/unit/common/test_json_home.py +++ b/keystone-moon/keystone/tests/unit/common/test_json_home.py @@ -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) diff --git a/keystone-moon/keystone/tests/unit/common/test_ldap.py b/keystone-moon/keystone/tests/unit/common/test_ldap.py index d3ce8cd2..e6e2c732 100644 --- a/keystone-moon/keystone/tests/unit/common/test_ldap.py +++ b/keystone-moon/keystone/tests/unit/common/test_ldap.py @@ -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): diff --git a/keystone-moon/keystone/tests/unit/common/test_manager.py b/keystone-moon/keystone/tests/unit/common/test_manager.py new file mode 100644 index 00000000..1bc19763 --- /dev/null +++ b/keystone-moon/keystone/tests/unit/common/test_manager.py @@ -0,0 +1,39 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import mock + +from keystone import catalog +from keystone.common import manager +from keystone.tests import unit + + +class TestCreateLegacyDriver(unit.BaseTestCase): + + @mock.patch('oslo_log.versionutils.report_deprecated_feature') + def test_class_is_properly_deprecated(self, mock_reporter): + Driver = manager.create_legacy_driver(catalog.CatalogDriverV8) + + # NOTE(dstanek): I want to subvert the requirement for this + # class to implement all of the abstractmethods. + Driver.__abstractmethods__ = set() + impl = Driver() + + details = { + 'as_of': 'Liberty', + 'what': 'keystone.catalog.core.Driver', + 'in_favor_of': 'keystone.catalog.core.CatalogDriverV8', + 'remove_in': 'N', + } + mock_reporter.assert_called_with(mock.ANY, mock.ANY, details) + + self.assertIsInstance(impl, catalog.CatalogDriverV8) diff --git a/keystone-moon/keystone/tests/unit/common/test_notifications.py b/keystone-moon/keystone/tests/unit/common/test_notifications.py index 2d872733..ec087c41 100644 --- a/keystone-moon/keystone/tests/unit/common/test_notifications.py +++ b/keystone-moon/keystone/tests/unit/common/test_notifications.py @@ -1007,7 +1007,7 @@ class TestCallbackRegistration(unit.BaseTestCase): with mock.patch('keystone.notifications.LOG', self.mock_log): notifications.register_event_callback( - CREATED_OPERATION, 'thing', C.callback) + CREATED_OPERATION, 'thing', C().callback) callback = 'keystone.tests.unit.common.test_notifications.C.callback' expected_log_data = { @@ -1026,7 +1026,7 @@ class TestCallbackRegistration(unit.BaseTestCase): with mock.patch('keystone.notifications.LOG', self.mock_log): notifications.register_event_callback( - CREATED_OPERATION, 'thing', [callback, C.callback]) + CREATED_OPERATION, 'thing', [callback, C().callback]) callback_1 = 'keystone.tests.unit.common.test_notifications.callback' callback_2 = 'keystone.tests.unit.common.test_notifications.C.callback' diff --git a/keystone-moon/keystone/tests/unit/common/test_sql_core.py b/keystone-moon/keystone/tests/unit/common/test_sql_core.py index 1f33cfc3..b110ed08 100644 --- a/keystone-moon/keystone/tests/unit/common/test_sql_core.py +++ b/keystone-moon/keystone/tests/unit/common/test_sql_core.py @@ -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()} diff --git a/keystone-moon/keystone/tests/unit/common/test_utils.py b/keystone-moon/keystone/tests/unit/common/test_utils.py index e8bac3c0..d52eb729 100644 --- a/keystone-moon/keystone/tests/unit/common/test_utils.py +++ b/keystone-moon/keystone/tests/unit/common/test_utils.py @@ -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) |