diff --git a/barbican/tests/api/test_resources.py b/barbican/tests/api/test_resources.py index 54a0719a6..d0c8c5faf 100644 --- a/barbican/tests/api/test_resources.py +++ b/barbican/tests/api/test_resources.py @@ -25,7 +25,6 @@ import urllib import mock import pecan -import testtools import webtest from barbican import api @@ -37,6 +36,7 @@ from barbican.common import validators import barbican.context from barbican.model import models from barbican.openstack.common import timeutils +from barbican.tests import utils LOG = logging.getLogger(__name__) @@ -129,7 +129,7 @@ def create_consumer(container_id, id_ref): return consumer -class SecretAllowAllMimeTypesDecoratorTest(testtools.TestCase): +class SecretAllowAllMimeTypesDecoratorTest(utils.BaseTestCase): def setUp(self): super(SecretAllowAllMimeTypesDecoratorTest, self).setUp() @@ -160,7 +160,7 @@ class SecretAllowAllMimeTypesDecoratorTest(testtools.TestCase): self._empty_function) -class FunctionalTest(testtools.TestCase): +class FunctionalTest(utils.BaseTestCase): def setUp(self): super(FunctionalTest, self).setUp() @@ -1820,8 +1820,8 @@ class WhenCreatingTypeOrdersUsingOrdersResource(FunctionalTest): self.queue_resource = mock.MagicMock() self.queue_resource.process_type_order.return_value = None - @testtools.skip("atiwari: remove skip once CR 111412 merged") def test_should_add_new_order(self): + self.skipTest("atiwari: remove skip once CR 111412 merged") resp = self.app.post_json( '/orders/', self.order_req ) @@ -1849,7 +1849,7 @@ class WhenCreatingTypeOrdersUsingOrdersResource(FunctionalTest): self.assertEqual(resp.status_int, 415) -class WhenAddingNavigationHrefs(testtools.TestCase): +class WhenAddingNavigationHrefs(utils.BaseTestCase): def setUp(self): super(WhenAddingNavigationHrefs, self).setUp() @@ -1890,7 +1890,7 @@ class WhenAddingNavigationHrefs(testtools.TestCase): self.assertNotIn('next', data_with_hrefs) -class TestingJsonSanitization(testtools.TestCase): +class TestingJsonSanitization(utils.BaseTestCase): def test_json_sanitization_without_array(self): json_without_array = {"name": "name", "algorithm": "AES", diff --git a/barbican/tests/api/test_resources_policy.py b/barbican/tests/api/test_resources_policy.py index 94c7dbf75..1c8c17a09 100644 --- a/barbican/tests/api/test_resources_policy.py +++ b/barbican/tests/api/test_resources_policy.py @@ -23,7 +23,6 @@ import os import mock from oslo.config import cfg -import testtools from webob import exc from barbican.api.controllers import consumers @@ -32,6 +31,7 @@ from barbican.api.controllers import secrets from barbican.api.controllers import versions from barbican import context from barbican.openstack.common import policy +from barbican.tests import utils CONF = cfg.CONF @@ -97,7 +97,7 @@ class ConsumerResource(TestableResource): controller_cls = consumers.ContainerConsumerController -class BaseTestCase(testtools.TestCase): +class BaseTestCase(utils.BaseTestCase): def setUp(self): super(BaseTestCase, self).setUp() diff --git a/barbican/tests/api/test_transport_keys_resource.py b/barbican/tests/api/test_transport_keys_resource.py index 51f25ccc5..5481e1d13 100644 --- a/barbican/tests/api/test_transport_keys_resource.py +++ b/barbican/tests/api/test_transport_keys_resource.py @@ -20,7 +20,6 @@ transport key resource classes. import mock import pecan -import testtools import webtest from barbican.api import app @@ -28,6 +27,7 @@ from barbican.api import controllers from barbican.common import exception as excep import barbican.context from barbican.model import models +from barbican.tests import utils def get_barbican_env(keystone_id): @@ -79,7 +79,7 @@ def create_transport_key(id_ref="id", return tkey -class FunctionalTest(testtools.TestCase): +class FunctionalTest(utils.BaseTestCase): def setUp(self): super(FunctionalTest, self).setUp() diff --git a/barbican/tests/common/test_utils.py b/barbican/tests/common/test_utils.py index e16907611..1bf5e4bd5 100644 --- a/barbican/tests/common/test_utils.py +++ b/barbican/tests/common/test_utils.py @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import mock -import testtools from barbican.common import utils +from barbican.tests import utils as test_utils -class WhenTestingHostnameForRefsGetter(testtools.TestCase): +class WhenTestingHostnameForRefsGetter(test_utils.BaseTestCase): def setUp(self): super(WhenTestingHostnameForRefsGetter, self).setUp() @@ -50,7 +50,7 @@ class WhenTestingHostnameForRefsGetter(testtools.TestCase): self.version)) -class WhenTestingAcceptEncodingGetter(testtools.TestCase): +class WhenTestingAcceptEncodingGetter(test_utils.BaseTestCase): def setUp(self): super(WhenTestingAcceptEncodingGetter, self).setUp() @@ -109,7 +109,7 @@ class WhenTestingAcceptEncodingGetter(testtools.TestCase): self.assertEqual("mock.Mock", fullname) -class WhenTestingGenerateFullClassnameForInstance(testtools.TestCase): +class WhenTestingGenerateFullClassnameForInstance(test_utils.BaseTestCase): def setUp(self): super(WhenTestingGenerateFullClassnameForInstance, self).setUp() diff --git a/barbican/tests/common/test_validators.py b/barbican/tests/common/test_validators.py index 29156c6e4..2ca2c0a1c 100644 --- a/barbican/tests/common/test_validators.py +++ b/barbican/tests/common/test_validators.py @@ -16,10 +16,9 @@ import datetime import unittest -import testtools - from barbican.common import exception as excep from barbican.common import validators +from barbican.tests import utils def suite(): @@ -30,7 +29,7 @@ def suite(): return suite -class WhenTestingValidatorsFunctions(testtools.TestCase): +class WhenTestingValidatorsFunctions(utils.BaseTestCase): def test_secret_too_big_is_false_for_small_secrets(self): data = b'\xb0' @@ -57,7 +56,7 @@ class WhenTestingValidatorsFunctions(testtools.TestCase): self.assertTrue(is_too_big) -class WhenTestingSecretValidator(testtools.TestCase): +class WhenTestingSecretValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingSecretValidator, self).setUp() @@ -309,7 +308,7 @@ class WhenTestingSecretValidator(testtools.TestCase): self.validator.validate(self.secret_req) -class WhenTestingOrderValidator(testtools.TestCase): +class WhenTestingOrderValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingOrderValidator, self).setUp() @@ -544,7 +543,7 @@ class WhenTestingOrderValidator(testtools.TestCase): ) -class WhenTestingContainerValidator(testtools.TestCase): +class WhenTestingContainerValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingContainerValidator, self).setUp() @@ -740,7 +739,7 @@ class WhenTestingContainerValidator(testtools.TestCase): self.assertEqual('secret_refs', exception.invalid_property) -class WhenTestingRSAContainerValidator(testtools.TestCase): +class WhenTestingRSAContainerValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingRSAContainerValidator, self).setUp() @@ -853,7 +852,7 @@ class WhenTestingRSAContainerValidator(testtools.TestCase): self.assertEqual('secret_refs', exception.invalid_property) -class WhenTestingCertificateContainerValidator(testtools.TestCase): +class WhenTestingCertificateContainerValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingCertificateContainerValidator, self).setUp() @@ -932,7 +931,7 @@ class WhenTestingCertificateContainerValidator(testtools.TestCase): self.assertEqual('secret_refs', exception.invalid_property) -class WhenTestingTransportKeyValidator(testtools.TestCase): +class WhenTestingTransportKeyValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingTransportKeyValidator, self).setUp() @@ -963,7 +962,7 @@ class WhenTestingTransportKeyValidator(testtools.TestCase): self.assertEqual('transport_key', exception.invalid_property) -class WhenTestingConsumerValidator(testtools.TestCase): +class WhenTestingConsumerValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingConsumerValidator, self).setUp() @@ -1006,7 +1005,7 @@ class WhenTestingConsumerValidator(testtools.TestCase): self.validator.validate(self.consumer_req) -class WhenTestingTypeOrderValidator(testtools.TestCase): +class WhenTestingTypeOrderValidator(utils.BaseTestCase): def setUp(self): super(WhenTestingTypeOrderValidator, self).setUp() diff --git a/barbican/tests/model/test_models.py b/barbican/tests/model/test_models.py index 05e052d66..581604064 100644 --- a/barbican/tests/model/test_models.py +++ b/barbican/tests/model/test_models.py @@ -15,12 +15,11 @@ import datetime -import testtools - from barbican.model import models +from barbican.tests import utils -class WhenCreatingNewSecret(testtools.TestCase): +class WhenCreatingNewSecret(utils.BaseTestCase): def setUp(self): super(WhenCreatingNewSecret, self).setUp() self.parsed_secret = {'name': 'name', @@ -42,7 +41,7 @@ class WhenCreatingNewSecret(testtools.TestCase): self.assertIsInstance(secret.expiration, datetime.datetime) -class WhenCreatingNewContainer(testtools.TestCase): +class WhenCreatingNewContainer(utils.BaseTestCase): def setUp(self): super(WhenCreatingNewContainer, self).setUp() self.parsed_container = {'name': 'name', @@ -113,7 +112,7 @@ class WhenCreatingNewContainer(testtools.TestCase): self.assertEqual(container.container_secrets[0].secret_id, '123456') -class WhenCreatingNewConsumer(testtools.TestCase): +class WhenCreatingNewConsumer(utils.BaseTestCase): def setUp(self): super(WhenCreatingNewConsumer, self).setUp() self.parsed_consumer = {'name': 'name', @@ -139,7 +138,7 @@ class WhenCreatingNewConsumer(testtools.TestCase): self.assertNotEqual(consumer_one.data_hash, consumer_three.data_hash) -class WhenProcessingJsonBlob(testtools.TestCase): +class WhenProcessingJsonBlob(utils.BaseTestCase): def setUp(self): super(WhenProcessingJsonBlob, self).setUp() self.json_blob = models.JsonBlob() diff --git a/barbican/tests/model/test_repositories.py b/barbican/tests/model/test_repositories.py index fdd5d339d..c6dc7e778 100644 --- a/barbican/tests/model/test_repositories.py +++ b/barbican/tests/model/test_repositories.py @@ -14,13 +14,13 @@ import mock from oslo.config import cfg import sqlalchemy.orm as sa_orm -import testtools from barbican.common import exception from barbican.model import repositories +from barbican.tests import utils -class WhenCleaningRepositoryPagingParameters(testtools.TestCase): +class WhenCleaningRepositoryPagingParameters(utils.BaseTestCase): def setUp(self): super(WhenCleaningRepositoryPagingParameters, self).setUp() diff --git a/barbican/tests/plugin/crypto/test_crypto.py b/barbican/tests/plugin/crypto/test_crypto.py index 89c479697..6c317187e 100644 --- a/barbican/tests/plugin/crypto/test_crypto.py +++ b/barbican/tests/plugin/crypto/test_crypto.py @@ -21,11 +21,11 @@ from Crypto.Util import asn1 from cryptography import fernet import mock import six -import testtools from barbican.model import models from barbican.plugin.crypto import crypto as plugin from barbican.plugin.crypto import simple_crypto as simple +from barbican.tests import utils class TestCryptoPlugin(plugin.CryptoPluginBase): @@ -68,7 +68,7 @@ class TestCryptoPlugin(plugin.CryptoPluginBase): return False -class WhenTestingSimpleCryptoPlugin(testtools.TestCase): +class WhenTestingSimpleCryptoPlugin(utils.BaseTestCase): def setUp(self): super(WhenTestingSimpleCryptoPlugin, self).setUp() diff --git a/barbican/tests/plugin/crypto/test_p11_crypto.py b/barbican/tests/plugin/crypto/test_p11_crypto.py index 7cf0bcea3..b26608cea 100644 --- a/barbican/tests/plugin/crypto/test_p11_crypto.py +++ b/barbican/tests/plugin/crypto/test_p11_crypto.py @@ -14,14 +14,14 @@ # limitations under the License. import mock -import testtools from barbican.model import models from barbican.plugin.crypto import crypto as plugin_import from barbican.plugin.crypto import p11_crypto +from barbican.tests import utils -class WhenTestingP11CryptoPlugin(testtools.TestCase): +class WhenTestingP11CryptoPlugin(utils.BaseTestCase): def setUp(self): super(WhenTestingP11CryptoPlugin, self).setUp() diff --git a/barbican/tests/plugin/interface/test_secret_store.py b/barbican/tests/plugin/interface/test_secret_store.py index 85dc0eea5..22f0cd8b8 100644 --- a/barbican/tests/plugin/interface/test_secret_store.py +++ b/barbican/tests/plugin/interface/test_secret_store.py @@ -14,9 +14,9 @@ # limitations under the License. import mock -import testtools from barbican.plugin.interface import secret_store as str +from barbican.tests import utils class TestSecretStore(str.SecretStoreBase): @@ -86,7 +86,7 @@ class TestSecretStoreWithTransportKey(str.SecretStoreBase): return True -class WhenTestingSecretStorePluginManager(testtools.TestCase): +class WhenTestingSecretStorePluginManager(utils.BaseTestCase): def setUp(self): super(WhenTestingSecretStorePluginManager, self).setUp() diff --git a/barbican/tests/plugin/test_dogtag.py b/barbican/tests/plugin/test_dogtag.py index 2f9b72afa..8a368a5f3 100644 --- a/barbican/tests/plugin/test_dogtag.py +++ b/barbican/tests/plugin/test_dogtag.py @@ -20,6 +20,8 @@ import mock from requests import exceptions as request_exceptions import testtools +from barbican.tests import utils + try: import barbican.plugin.dogtag as dogtag_import import barbican.plugin.interface.certificate_manager as cm @@ -34,7 +36,7 @@ except ImportError: @testtools.skipIf(not imports_ok, "Dogtag imports not available") -class WhenTestingDogtagKRAPlugin(testtools.TestCase): +class WhenTestingDogtagKRAPlugin(utils.BaseTestCase): def setUp(self): super(WhenTestingDogtagKRAPlugin, self).setUp() @@ -187,7 +189,7 @@ class WhenTestingDogtagKRAPlugin(testtools.TestCase): @testtools.skipIf(not imports_ok, "Dogtag imports not available") -class WhenTestingDogtagCAPlugin(testtools.TestCase): +class WhenTestingDogtagCAPlugin(utils.BaseTestCase): def setUp(self): super(WhenTestingDogtagCAPlugin, self).setUp() diff --git a/barbican/tests/plugin/test_kmip.py b/barbican/tests/plugin/test_kmip.py index 30db7381f..1bced17d5 100644 --- a/barbican/tests/plugin/test_kmip.py +++ b/barbican/tests/plugin/test_kmip.py @@ -17,6 +17,7 @@ import mock import testtools from barbican.plugin.interface import secret_store +from barbican.tests import utils try: from kmip.core import attributes as attr @@ -36,7 +37,7 @@ except ImportError: @testtools.skipIf(not kmip_available, "KMIP imports not available") -class WhenTestingKMIPSecretStore(testtools.TestCase): +class WhenTestingKMIPSecretStore(utils.BaseTestCase): """Test using the KMIP server backend for SecretStore.""" def setUp(self): diff --git a/barbican/tests/plugin/test_store_crypto.py b/barbican/tests/plugin/test_store_crypto.py index 23fe341cd..1f66aee15 100644 --- a/barbican/tests/plugin/test_store_crypto.py +++ b/barbican/tests/plugin/test_store_crypto.py @@ -12,15 +12,16 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import testtools + +import mock import barbican.model.repositories as repo from barbican.plugin.interface import secret_store from barbican.plugin import store_crypto -import mock +from barbican.tests import utils -class WhenStoreCryptoAdapterPlugin(testtools.TestCase): +class WhenStoreCryptoAdapterPlugin(utils.BaseTestCase): def setUp(self): super(WhenStoreCryptoAdapterPlugin, self).setUp() @@ -41,7 +42,7 @@ class WhenStoreCryptoAdapterPlugin(testtools.TestCase): self.store_crypto.generate_supports(self.key_spec)) -class WhenTestingStoreCrypto(testtools.TestCase): +class WhenTestingStoreCrypto(utils.BaseTestCase): def setUp(self): super(WhenTestingStoreCrypto, self).setUp() diff --git a/barbican/tests/plugin/test_symantec.py b/barbican/tests/plugin/test_symantec.py index 062cd5583..759c75286 100644 --- a/barbican/tests/plugin/test_symantec.py +++ b/barbican/tests/plugin/test_symantec.py @@ -23,9 +23,11 @@ except ImportError: # Symantec imports probably not available imports_ok = False +from barbican.tests import utils + @testtools.skipIf(not imports_ok, "Symantec imports not available") -class WhenTestingSymantecPlugin(testtools.TestCase): +class WhenTestingSymantecPlugin(utils.BaseTestCase): def setUp(self): super(WhenTestingSymantecPlugin, self).setUp() diff --git a/barbican/tests/plugin/util/test_mime_types.py b/barbican/tests/plugin/util/test_mime_types.py index 5076e91c6..765a69a20 100644 --- a/barbican/tests/plugin/util/test_mime_types.py +++ b/barbican/tests/plugin/util/test_mime_types.py @@ -13,13 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -import testtools - from barbican.model import models from barbican.plugin.util import mime_types +from barbican.tests import utils -class WhenTestingIsBase64ProcessingNeeded(testtools.TestCase): +class WhenTestingIsBase64ProcessingNeeded(utils.BaseTestCase): def test_is_base64_needed(self): r = mime_types.is_base64_processing_needed('application/octet-stream', @@ -48,7 +47,7 @@ class WhenTestingIsBase64ProcessingNeeded(testtools.TestCase): self.assertFalse(r) -class WhenTestingIsBase64ProcessingSupported(testtools.TestCase): +class WhenTestingIsBase64ProcessingSupported(utils.BaseTestCase): def test_is_base64_supported_application_octet_stream(self): r = mime_types.is_base64_encoding_supported('application/octet-stream') @@ -62,7 +61,7 @@ class WhenTestingIsBase64ProcessingSupported(testtools.TestCase): self.assertFalse(r) -class WhenTestingAugmentFieldsWithContentTypes(testtools.TestCase): +class WhenTestingAugmentFieldsWithContentTypes(utils.BaseTestCase): def setUp(self): super(WhenTestingAugmentFieldsWithContentTypes, self).setUp() @@ -113,7 +112,7 @@ class WhenTestingAugmentFieldsWithContentTypes(testtools.TestCase): self.assertEqual(self.datum.content_type, content_types['default']) -class WhenTestingNormalizationOfMIMETypes(testtools.TestCase): +class WhenTestingNormalizationOfMIMETypes(utils.BaseTestCase): def test_plain_text_normalization(self): mimes = ['text/plain', diff --git a/barbican/tests/tasks/test_certificate_resources.py b/barbican/tests/tasks/test_certificate_resources.py index ec1ca1435..894dbc406 100644 --- a/barbican/tests/tasks/test_certificate_resources.py +++ b/barbican/tests/tasks/test_certificate_resources.py @@ -14,14 +14,14 @@ # limitations under the License. import mock -import testtools from barbican.common import hrefs from barbican.plugin.interface import certificate_manager as cert_man from barbican.tasks import certificate_resources as cert_res +from barbican.tests import utils -class WhenPerformingPrivateOperations(testtools.TestCase): +class WhenPerformingPrivateOperations(utils.BaseTestCase): """Tests private methods within certificate_resources.py.""" def test_get_plugin_meta(self): @@ -94,7 +94,7 @@ class WhenPerformingPrivateOperations(testtools.TestCase): 'between the expected and test dicts') -class WhenIssuingCertificateRequests(testtools.TestCase): +class WhenIssuingCertificateRequests(utils.BaseTestCase): """Tests the 'issue_certificate_request()' function.""" def setUp(self): diff --git a/barbican/tests/tasks/test_resources.py b/barbican/tests/tasks/test_resources.py index e2a888d02..c6ade935a 100644 --- a/barbican/tests/tasks/test_resources.py +++ b/barbican/tests/tasks/test_resources.py @@ -14,15 +14,15 @@ # limitations under the License. import mock -import testtools from barbican.model import models from barbican.openstack.common import gettextutils as u from barbican.openstack.common import timeutils from barbican.tasks import resources +from barbican.tests import utils -class WhenBeginningOrder(testtools.TestCase): +class WhenBeginningOrder(utils.BaseTestCase): def setUp(self): super(WhenBeginningOrder, self).setUp() @@ -171,7 +171,7 @@ class WhenBeginningOrder(testtools.TestCase): ) -class WhenBeginningKeyTypeOrder(testtools.TestCase): +class WhenBeginningKeyTypeOrder(utils.BaseTestCase): def setUp(self): super(WhenBeginningKeyTypeOrder, self).setUp() @@ -325,7 +325,7 @@ class WhenBeginningKeyTypeOrder(testtools.TestCase): ) -class WhenBeginningAsymmetricTypeOrder(testtools.TestCase): +class WhenBeginningAsymmetricTypeOrder(utils.BaseTestCase): def setUp(self): super(WhenBeginningAsymmetricTypeOrder, self).setUp() diff --git a/barbican/tests/utils.py b/barbican/tests/utils.py index ca5cc8230..40c348c6a 100644 --- a/barbican/tests/utils.py +++ b/barbican/tests/utils.py @@ -12,10 +12,10 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import testtools +import oslotest.base as oslotest -class BaseTestCase(testtools.TestCase): +class BaseTestCase(oslotest.BaseTestCase): def setUp(self): super(BaseTestCase, self).setUp() self.order_id = 'order1234' diff --git a/functionaltests/api/base.py b/functionaltests/api/base.py index 9fd748b1e..9e9120fce 100644 --- a/functionaltests/api/base.py +++ b/functionaltests/api/base.py @@ -13,11 +13,13 @@ 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 oslotest.base as oslotest + from tempest import auth from tempest import clients from tempest.common import rest_client from tempest import config -import testtools + CONF = config.CONF @@ -36,7 +38,7 @@ class BarbicanClient(rest_client.RestClient): self.endpoint_url = 'publicURL' -class TestCase(testtools.TestCase): +class TestCase(oslotest.BaseTestCase): def setUp(self): super(TestCase, self).setUp() diff --git a/test-requirements.txt b/test-requirements.txt index 28e510ee4..2daa9e62c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,6 +2,7 @@ coverage>=3.6 discover hacking>=0.8.0,<0.9 mock>=1.0 +oslotest>=1.1.0.0a1 testrepository>=0.0.18 testtools>=0.9.34