From 3df667582c20368a24a885bf4491f34d85ec194e Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 11:53:33 -0500 Subject: [PATCH] Use unittest.mock instead of third party mock Now that we no longer support py27, we can use the standard library unittest.mock module instead of the third party mock lib. Change-Id: Ifd0d1b8aa419e39361e76a4f846cb4eeaf0d46ca Signed-off-by: Sean McGinnis --- karbor/tests/base.py | 2 +- karbor/tests/unit/api/test_common.py | 6 +++--- karbor/tests/unit/api/v1/test_copies.py | 5 +++-- .../tests/unit/api/v1/test_operation_logs.py | 3 ++- karbor/tests/unit/api/v1/test_plans.py | 3 ++- karbor/tests/unit/api/v1/test_protectables.py | 3 ++- karbor/tests/unit/api/v1/test_providers.py | 4 ++-- .../tests/unit/api/v1/test_quota_classes.py | 3 ++- karbor/tests/unit/api/v1/test_quotas.py | 3 ++- karbor/tests/unit/api/v1/test_restores.py | 3 ++- .../unit/api/v1/test_scheduled_operation.py | 3 ++- karbor/tests/unit/api/v1/test_services.py | 3 ++- karbor/tests/unit/api/v1/test_triggers.py | 3 ++- .../tests/unit/api/v1/test_verifications.py | 3 ++- .../tests/unit/clients/test_cinder_client.py | 3 ++- karbor/tests/unit/clients/test_eisoo.py | 2 +- .../tests/unit/clients/test_freezer_client.py | 2 +- .../tests/unit/clients/test_glance_client.py | 3 ++- .../tests/unit/clients/test_manila_client.py | 2 +- .../tests/unit/clients/test_neutron_client.py | 3 ++- .../tests/unit/clients/test_trove_client.py | 2 +- karbor/tests/unit/clients/test_utils.py | 3 ++- .../common/test_karbor_keystone_plugin.py | 9 ++++----- karbor/tests/unit/common/test_notification.py | 12 ++++++------ karbor/tests/unit/objects/test_base.py | 2 +- .../unit/objects/test_checkpoint_record.py | 3 ++- .../tests/unit/objects/test_operation_log.py | 2 +- karbor/tests/unit/objects/test_plan.py | 2 +- karbor/tests/unit/objects/test_restore.py | 2 +- .../unit/objects/test_scheduled_operation.py | 3 ++- .../objects/test_scheduled_operation_log.py | 3 ++- .../objects/test_scheduled_operation_state.py | 3 ++- karbor/tests/unit/objects/test_service.py | 2 +- karbor/tests/unit/objects/test_trigger.py | 3 ++- .../tests/unit/objects/test_verification.py | 2 +- .../engine/triggers/test_trigger_manager.py | 3 ++- .../triggers/timetrigger/test_time_trigger.py | 3 ++- .../test_time_trigger_multi_node.py | 3 ++- .../operations/test_protect_operation.py | 2 +- .../operations/test_retention_operation.py | 2 +- .../operationengine/test_karbor_client.py | 2 +- .../unit/operationengine/test_manager.py | 3 ++- .../operationengine/test_operation_manager.py | 2 +- .../test_user_trust_manager.py | 2 +- .../test_database_protectable_plugin.py | 10 +++++----- .../plugins/test_image_protectable_plugin.py | 10 ++++++---- .../test_network_protectable_plugin.py | 9 +++++---- .../plugins/test_pod_protectable_plugin.py | 15 +++++++-------- .../plugins/test_server_protectable_plugin.py | 11 ++++++----- .../plugins/test_share_protectable_plugin.py | 10 +++++----- .../plugins/test_volume_protectable_plugin.py | 3 ++- karbor/tests/unit/protection/fakes.py | 13 ++++++------- .../protection/test_checkpoint_collection.py | 2 +- .../test_cinder_freezer_protection_plugin.py | 8 ++++---- .../protection/test_cinder_glance_plugin.py | 8 +++++--- .../test_cinder_protection_plugin.py | 10 ++++++---- .../test_cinder_snapshot_protection_plugin.py | 8 +++++--- .../unit/protection/test_client_factory.py | 2 +- .../test_database_protection_plugin.py | 10 +++++----- .../test_glance_protection_plugin.py | 10 ++++++---- karbor/tests/unit/protection/test_manager.py | 2 +- .../test_manila_protection_plugin.py | 8 +++++--- .../test_neutron_protection_plugin.py | 6 ++++-- .../protection/test_nova_protection_plugin.py | 3 ++- .../protection/test_pod_protection_plugin.py | 19 +++++++++---------- karbor/tests/unit/protection/test_provider.py | 5 +++-- .../unit/protection/test_resource_flow.py | 5 +++-- .../unit/protection/test_s3_bank_plugin.py | 12 +++++++----- .../unit/protection/test_swift_bank_plugin.py | 14 ++++++++------ karbor/tests/unit/test_exception.py | 8 ++++---- karbor/tests/unit/test_rpc.py | 2 +- karbor/tests/unit/test_service.py | 3 ++- 72 files changed, 204 insertions(+), 159 deletions(-) diff --git a/karbor/tests/base.py b/karbor/tests/base.py index ceef5b8b..2363ccab 100644 --- a/karbor/tests/base.py +++ b/karbor/tests/base.py @@ -11,9 +11,9 @@ # under the License. import logging +from unittest import mock import fixtures -import mock from oslo_config import cfg from oslo_messaging import conffixture as messaging_conffixture from oslo_utils import timeutils diff --git a/karbor/tests/unit/api/test_common.py b/karbor/tests/unit/api/test_common.py index 128f60b8..664d601a 100644 --- a/karbor/tests/unit/api/test_common.py +++ b/karbor/tests/unit/api/test_common.py @@ -14,13 +14,13 @@ Test suites for 'common' code used throughout the OpenStack HTTP API. """ -import mock +from unittest import mock + +from oslo_config import cfg from testtools import matchers import webob import webob.exc -from oslo_config import cfg - from karbor.api import common from karbor.tests import base diff --git a/karbor/tests/unit/api/v1/test_copies.py b/karbor/tests/unit/api/v1/test_copies.py index a8fed276..ebbca70a 100644 --- a/karbor/tests/unit/api/v1/test_copies.py +++ b/karbor/tests/unit/api/v1/test_copies.py @@ -9,14 +9,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from mock import mock +from unittest import mock + +from webob import exc from karbor.api.v1 import copies from karbor import context from karbor import exception from karbor.tests import base from karbor.tests.unit.api import fakes -from webob import exc PROVIDER_ID_1 = 'efc6a88b-9096-4bb6-8634-cda182a6e12a' PROVIDER_ID_2 = '3241a88b-9096-4bb6-8634-cda182a6e12a' diff --git a/karbor/tests/unit/api/v1/test_operation_logs.py b/karbor/tests/unit/api/v1/test_operation_logs.py index 15e999b8..373072a5 100644 --- a/karbor/tests/unit/api/v1/test_operation_logs.py +++ b/karbor/tests/unit/api/v1/test_operation_logs.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_plans.py b/karbor/tests/unit/api/v1/test_plans.py index 3bf179ca..32f2458e 100644 --- a/karbor/tests/unit/api/v1/test_plans.py +++ b/karbor/tests/unit/api/v1/test_plans.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_protectables.py b/karbor/tests/unit/api/v1/test_protectables.py index 850d57b3..0679b872 100644 --- a/karbor/tests/unit/api/v1/test_protectables.py +++ b/karbor/tests/unit/api/v1/test_protectables.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_providers.py b/karbor/tests/unit/api/v1/test_providers.py index f661ab27..eabfd7ec 100644 --- a/karbor/tests/unit/api/v1/test_providers.py +++ b/karbor/tests/unit/api/v1/test_providers.py @@ -11,9 +11,9 @@ # under the License. -import mock -from oslo_config import cfg +from unittest import mock +from oslo_config import cfg from webob import exc from karbor.api.v1 import providers diff --git a/karbor/tests/unit/api/v1/test_quota_classes.py b/karbor/tests/unit/api/v1/test_quota_classes.py index 5cfd1a8a..ef0e8267 100644 --- a/karbor/tests/unit/api/v1/test_quota_classes.py +++ b/karbor/tests/unit/api/v1/test_quota_classes.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_quotas.py b/karbor/tests/unit/api/v1/test_quotas.py index ed990ddf..bb6e56f7 100644 --- a/karbor/tests/unit/api/v1/test_quotas.py +++ b/karbor/tests/unit/api/v1/test_quotas.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_restores.py b/karbor/tests/unit/api/v1/test_restores.py index 72cd4f3d..cfafcab9 100644 --- a/karbor/tests/unit/api/v1/test_restores.py +++ b/karbor/tests/unit/api/v1/test_restores.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/api/v1/test_scheduled_operation.py b/karbor/tests/unit/api/v1/test_scheduled_operation.py index 122174b3..a3c58fc4 100644 --- a/karbor/tests/unit/api/v1/test_scheduled_operation.py +++ b/karbor/tests/unit/api/v1/test_scheduled_operation.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import uuidutils from webob import exc diff --git a/karbor/tests/unit/api/v1/test_services.py b/karbor/tests/unit/api/v1/test_services.py index 91b952f1..0dffc802 100644 --- a/karbor/tests/unit/api/v1/test_services.py +++ b/karbor/tests/unit/api/v1/test_services.py @@ -9,7 +9,8 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from mock import mock +from unittest import mock + from webob import exc from karbor.api.v1 import services diff --git a/karbor/tests/unit/api/v1/test_triggers.py b/karbor/tests/unit/api/v1/test_triggers.py index e9ca0c85..e99e390a 100755 --- a/karbor/tests/unit/api/v1/test_triggers.py +++ b/karbor/tests/unit/api/v1/test_triggers.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. from datetime import datetime -import mock +from unittest import mock + from webob import exc from karbor.api.v1 import triggers as trigger_api diff --git a/karbor/tests/unit/api/v1/test_verifications.py b/karbor/tests/unit/api/v1/test_verifications.py index ba892dad..62ebb67a 100755 --- a/karbor/tests/unit/api/v1/test_verifications.py +++ b/karbor/tests/unit/api/v1/test_verifications.py @@ -11,7 +11,8 @@ # under the License. -import mock +from unittest import mock + from oslo_config import cfg from webob import exc diff --git a/karbor/tests/unit/clients/test_cinder_client.py b/karbor/tests/unit/clients/test_cinder_client.py index 85d3b378..5fd145c2 100644 --- a/karbor/tests/unit/clients/test_cinder_client.py +++ b/karbor/tests/unit/clients/test_cinder_client.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from karbor.context import RequestContext diff --git a/karbor/tests/unit/clients/test_eisoo.py b/karbor/tests/unit/clients/test_eisoo.py index fa3b5707..c3964119 100644 --- a/karbor/tests/unit/clients/test_eisoo.py +++ b/karbor/tests/unit/clients/test_eisoo.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor.context import RequestContext from karbor.services.protection.clients import eisoo diff --git a/karbor/tests/unit/clients/test_freezer_client.py b/karbor/tests/unit/clients/test_freezer_client.py index 53e29587..be2bacf6 100644 --- a/karbor/tests/unit/clients/test_freezer_client.py +++ b/karbor/tests/unit/clients/test_freezer_client.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from keystoneauth1 import session as keystone_session from oslo_config import cfg diff --git a/karbor/tests/unit/clients/test_glance_client.py b/karbor/tests/unit/clients/test_glance_client.py index 8c595cb2..1a008196 100644 --- a/karbor/tests/unit/clients/test_glance_client.py +++ b/karbor/tests/unit/clients/test_glance_client.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from karbor.context import RequestContext diff --git a/karbor/tests/unit/clients/test_manila_client.py b/karbor/tests/unit/clients/test_manila_client.py index d795d27a..360794e9 100644 --- a/karbor/tests/unit/clients/test_manila_client.py +++ b/karbor/tests/unit/clients/test_manila_client.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from keystoneauth1 import session as keystone_session from oslo_config import cfg diff --git a/karbor/tests/unit/clients/test_neutron_client.py b/karbor/tests/unit/clients/test_neutron_client.py index 060603a6..980099b5 100644 --- a/karbor/tests/unit/clients/test_neutron_client.py +++ b/karbor/tests/unit/clients/test_neutron_client.py @@ -11,7 +11,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from karbor.context import RequestContext diff --git a/karbor/tests/unit/clients/test_trove_client.py b/karbor/tests/unit/clients/test_trove_client.py index 9bc21948..d0727b40 100644 --- a/karbor/tests/unit/clients/test_trove_client.py +++ b/karbor/tests/unit/clients/test_trove_client.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from keystoneauth1 import session as keystone_session from oslo_config import cfg diff --git a/karbor/tests/unit/clients/test_utils.py b/karbor/tests/unit/clients/test_utils.py index 174654d4..390e4d94 100644 --- a/karbor/tests/unit/clients/test_utils.py +++ b/karbor/tests/unit/clients/test_utils.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_config import cfg from karbor.common import karbor_keystone_plugin as kkp diff --git a/karbor/tests/unit/common/test_karbor_keystone_plugin.py b/karbor/tests/unit/common/test_karbor_keystone_plugin.py index 83282504..caef1eb0 100644 --- a/karbor/tests/unit/common/test_karbor_keystone_plugin.py +++ b/karbor/tests/unit/common/test_karbor_keystone_plugin.py @@ -10,15 +10,14 @@ # License for the specific language governing permissions and limitations # under the License. -import mock - - -from karbor.common import karbor_keystone_plugin -from karbor.tests import base +from unittest import mock from oslo_config import cfg from oslo_config import fixture +from karbor.common import karbor_keystone_plugin +from karbor.tests import base + class KarborKeystonePluginTest(base.TestCase): diff --git a/karbor/tests/unit/common/test_notification.py b/karbor/tests/unit/common/test_notification.py index 2227c0cd..46a87af8 100644 --- a/karbor/tests/unit/common/test_notification.py +++ b/karbor/tests/unit/common/test_notification.py @@ -11,8 +11,8 @@ # under the License. """The notification module.""" -from mock import Mock -from mock import patch +from unittest import mock +from unittest.mock import patch from karbor.common import notification from karbor.common.notification import EndNotification @@ -86,7 +86,7 @@ class TestKarborNotification(base.TestCase): def setUp(self): super(TestKarborNotification, self).setUp() - self.test_n = KarborTestNotification(Mock(), request=Mock()) + self.test_n = KarborTestNotification(mock.Mock(), request=mock.Mock()) def test_missing_required_start_traits(self): self.assertRaisesRegex(exception.InvalidInput, @@ -164,10 +164,10 @@ class TestKarborNotification(base.TestCase): def _test_notify_callback(self, fn, *args, **kwargs): with patch.object(rpc, 'get_notifier') as notifier: - mock_callback = Mock() + mock_callback = mock.Mock() self.test_n.register_notify_callback(mock_callback) - mock_context = Mock() - mock_context.notification = Mock() + mock_context = mock.Mock() + mock_context.notification = mock.Mock() self.test_n.context = mock_context fn(*args, **kwargs) self.assertTrue(notifier().info.called) diff --git a/karbor/tests/unit/objects/test_base.py b/karbor/tests/unit/objects/test_base.py index f8c43881..988f698a 100644 --- a/karbor/tests/unit/objects/test_base.py +++ b/karbor/tests/unit/objects/test_base.py @@ -11,7 +11,7 @@ # under the License. import datetime -import mock +from unittest import mock from iso8601 import iso8601 from oslo_utils import uuidutils diff --git a/karbor/tests/unit/objects/test_checkpoint_record.py b/karbor/tests/unit/objects/test_checkpoint_record.py index 7bc6acb3..5b288626 100644 --- a/karbor/tests/unit/objects/test_checkpoint_record.py +++ b/karbor/tests/unit/objects/test_checkpoint_record.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils from karbor import objects diff --git a/karbor/tests/unit/objects/test_operation_log.py b/karbor/tests/unit/objects/test_operation_log.py index c07c62dd..793cac8b 100644 --- a/karbor/tests/unit/objects/test_operation_log.py +++ b/karbor/tests/unit/objects/test_operation_log.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import objects from karbor.tests.unit import fake_operation_log diff --git a/karbor/tests/unit/objects/test_plan.py b/karbor/tests/unit/objects/test_plan.py index 2dcdb6f0..3f10de11 100644 --- a/karbor/tests/unit/objects/test_plan.py +++ b/karbor/tests/unit/objects/test_plan.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_serialization import jsonutils diff --git a/karbor/tests/unit/objects/test_restore.py b/karbor/tests/unit/objects/test_restore.py index e69f98bd..b52a7797 100644 --- a/karbor/tests/unit/objects/test_restore.py +++ b/karbor/tests/unit/objects/test_restore.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import objects from karbor.tests.unit import fake_restore diff --git a/karbor/tests/unit/objects/test_scheduled_operation.py b/karbor/tests/unit/objects/test_scheduled_operation.py index 8efd95f5..3640d897 100644 --- a/karbor/tests/unit/objects/test_scheduled_operation.py +++ b/karbor/tests/unit/objects/test_scheduled_operation.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_serialization import jsonutils from oslo_utils import timeutils diff --git a/karbor/tests/unit/objects/test_scheduled_operation_log.py b/karbor/tests/unit/objects/test_scheduled_operation_log.py index 26367d53..fb04e9e5 100644 --- a/karbor/tests/unit/objects/test_scheduled_operation_log.py +++ b/karbor/tests/unit/objects/test_scheduled_operation_log.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils from karbor import exception diff --git a/karbor/tests/unit/objects/test_scheduled_operation_state.py b/karbor/tests/unit/objects/test_scheduled_operation_state.py index 3ce841a3..3a72e4ea 100644 --- a/karbor/tests/unit/objects/test_scheduled_operation_state.py +++ b/karbor/tests/unit/objects/test_scheduled_operation_state.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_utils import timeutils from karbor import context diff --git a/karbor/tests/unit/objects/test_service.py b/karbor/tests/unit/objects/test_service.py index 16e90e84..5936c2ff 100644 --- a/karbor/tests/unit/objects/test_service.py +++ b/karbor/tests/unit/objects/test_service.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import objects from karbor.tests.unit import fake_service diff --git a/karbor/tests/unit/objects/test_trigger.py b/karbor/tests/unit/objects/test_trigger.py index 13114c6c..5d7c98b2 100644 --- a/karbor/tests/unit/objects/test_trigger.py +++ b/karbor/tests/unit/objects/test_trigger.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_serialization import jsonutils from oslo_utils import timeutils diff --git a/karbor/tests/unit/objects/test_verification.py b/karbor/tests/unit/objects/test_verification.py index e28f90e9..a828fb86 100644 --- a/karbor/tests/unit/objects/test_verification.py +++ b/karbor/tests/unit/objects/test_verification.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import objects from karbor.tests.unit import fake_verification diff --git a/karbor/tests/unit/operationengine/engine/triggers/test_trigger_manager.py b/karbor/tests/unit/operationengine/engine/triggers/test_trigger_manager.py index 1d74da2a..4fc7c5d0 100644 --- a/karbor/tests/unit/operationengine/engine/triggers/test_trigger_manager.py +++ b/karbor/tests/unit/operationengine/engine/triggers/test_trigger_manager.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from stevedore import extension as import_driver from karbor import exception diff --git a/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger.py b/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger.py index f42949c7..2fd27178 100644 --- a/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger.py +++ b/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger.py @@ -12,7 +12,8 @@ from datetime import datetime from datetime import timedelta import eventlet -import mock +from unittest import mock + from oslo_config import cfg from karbor import exception diff --git a/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger_multi_node.py b/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger_multi_node.py index eeaa668f..8e332c6d 100644 --- a/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger_multi_node.py +++ b/karbor/tests/unit/operationengine/engine/triggers/timetrigger/test_time_trigger_multi_node.py @@ -16,7 +16,8 @@ from datetime import timedelta import eventlet import functools import heapq -import mock +from unittest import mock + from oslo_config import cfg from oslo_utils import uuidutils diff --git a/karbor/tests/unit/operationengine/operations/test_protect_operation.py b/karbor/tests/unit/operationengine/operations/test_protect_operation.py index 5b3f8b00..997b01fa 100644 --- a/karbor/tests/unit/operationengine/operations/test_protect_operation.py +++ b/karbor/tests/unit/operationengine/operations/test_protect_operation.py @@ -11,7 +11,7 @@ # under the License. from datetime import datetime -import mock +from unittest import mock from karbor.common import constants from karbor import context diff --git a/karbor/tests/unit/operationengine/operations/test_retention_operation.py b/karbor/tests/unit/operationengine/operations/test_retention_operation.py index f35160ae..b896ac31 100644 --- a/karbor/tests/unit/operationengine/operations/test_retention_operation.py +++ b/karbor/tests/unit/operationengine/operations/test_retention_operation.py @@ -12,7 +12,7 @@ from datetime import datetime from datetime import timedelta -import mock +from unittest import mock from karbor.common import constants from karbor import context diff --git a/karbor/tests/unit/operationengine/test_karbor_client.py b/karbor/tests/unit/operationengine/test_karbor_client.py index f51317ad..0cb4b686 100644 --- a/karbor/tests/unit/operationengine/test_karbor_client.py +++ b/karbor/tests/unit/operationengine/test_karbor_client.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_config import cfg diff --git a/karbor/tests/unit/operationengine/test_manager.py b/karbor/tests/unit/operationengine/test_manager.py index c6d275f3..2c62f508 100644 --- a/karbor/tests/unit/operationengine/test_manager.py +++ b/karbor/tests/unit/operationengine/test_manager.py @@ -10,7 +10,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from oslo_messaging.rpc import dispatcher as rpc_dispatcher from karbor.common import constants diff --git a/karbor/tests/unit/operationengine/test_operation_manager.py b/karbor/tests/unit/operationengine/test_operation_manager.py index 44f35eac..723c68b2 100644 --- a/karbor/tests/unit/operationengine/test_operation_manager.py +++ b/karbor/tests/unit/operationengine/test_operation_manager.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import exception from karbor.services.operationengine import operation_manager diff --git a/karbor/tests/unit/operationengine/test_user_trust_manager.py b/karbor/tests/unit/operationengine/test_user_trust_manager.py index f597168c..3ce045f1 100644 --- a/karbor/tests/unit/operationengine/test_user_trust_manager.py +++ b/karbor/tests/unit/operationengine/test_user_trust_manager.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor import context from karbor.services.operationengine import user_trust_manager diff --git a/karbor/tests/unit/plugins/test_database_protectable_plugin.py b/karbor/tests/unit/plugins/test_database_protectable_plugin.py index a232ea4c..6d4ef2cf 100644 --- a/karbor/tests/unit/plugins/test_database_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_database_protectable_plugin.py @@ -11,18 +11,18 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from troveclient.v1 import instances + from karbor.context import RequestContext from karbor.resource import Resource # Need to register trove_client from karbor.services.protection.clients import trove # noqa from karbor.services.protection.protectable_plugins.database \ import DatabaseInstanceProtectablePlugin - from karbor.tests import base -import mock - -from oslo_config import cfg -from troveclient.v1 import instances class DatabaseInstanceProtectablePluginTest(base.TestCase): diff --git a/karbor/tests/unit/plugins/test_image_protectable_plugin.py b/karbor/tests/unit/plugins/test_image_protectable_plugin.py index 14fea43d..5c45b0c3 100644 --- a/karbor/tests/unit/plugins/test_image_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_image_protectable_plugin.py @@ -11,17 +11,19 @@ # under the License. from collections import namedtuple +from unittest import mock + from glanceclient.v2 import images +from keystoneauth1 import session as keystone_session +from novaclient.v2 import servers +from oslo_config import cfg + from karbor.common import constants from karbor.context import RequestContext from karbor import resource from karbor.services.protection.protectable_plugins.image import \ ImageProtectablePlugin from karbor.tests import base -from keystoneauth1 import session as keystone_session -import mock -from novaclient.v2 import servers -from oslo_config import cfg CONF = cfg.CONF diff --git a/karbor/tests/unit/plugins/test_network_protectable_plugin.py b/karbor/tests/unit/plugins/test_network_protectable_plugin.py index ee7b0919..7ad05e21 100644 --- a/karbor/tests/unit/plugins/test_network_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_network_protectable_plugin.py @@ -11,7 +11,11 @@ # under the License. from collections import namedtuple -import mock +from unittest import mock + +from keystoneauth1 import session as keystone_session +from neutronclient.v2_0 import client +from oslo_config import cfg from karbor.common import constants from karbor.context import RequestContext @@ -19,9 +23,6 @@ from karbor import resource from karbor.services.protection.protectable_plugins.network import \ NetworkProtectablePlugin from karbor.tests import base -from keystoneauth1 import session as keystone_session -from neutronclient.v2_0 import client -from oslo_config import cfg CONF = cfg.CONF diff --git a/karbor/tests/unit/plugins/test_pod_protectable_plugin.py b/karbor/tests/unit/plugins/test_pod_protectable_plugin.py index 64b3b143..6fa9c5ad 100644 --- a/karbor/tests/unit/plugins/test_pod_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_pod_protectable_plugin.py @@ -10,22 +10,21 @@ # License for the specific language governing permissions and limitations # under the License. -from karbor.context import RequestContext -from karbor.resource import Resource -from karbor.services.protection.clients import k8s # noqa -from karbor.services.protection.protectable_plugins.pod \ - import K8sPodProtectablePlugin +from unittest import mock +import uuid from kubernetes.client.models.v1_object_meta import V1ObjectMeta from kubernetes.client.models.v1_pod import V1Pod from kubernetes.client.models.v1_pod_list import V1PodList from kubernetes.client.models.v1_pod_status import V1PodStatus - from oslo_config import cfg +from karbor.context import RequestContext +from karbor.resource import Resource +from karbor.services.protection.clients import k8s # noqa +from karbor.services.protection.protectable_plugins.pod \ + import K8sPodProtectablePlugin from karbor.tests import base -import mock -import uuid class PodProtectablePluginTest(base.TestCase): diff --git a/karbor/tests/unit/plugins/test_server_protectable_plugin.py b/karbor/tests/unit/plugins/test_server_protectable_plugin.py index 8eab4cb8..814013e2 100644 --- a/karbor/tests/unit/plugins/test_server_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_server_protectable_plugin.py @@ -11,16 +11,17 @@ # under the License. import collections +from unittest import mock + +from keystoneauth1 import session as keystone_session +from novaclient.v2 import servers +from oslo_config import cfg + from karbor.context import RequestContext from karbor.resource import Resource from karbor.services.protection.protectable_plugins.server \ import ServerProtectablePlugin - from karbor.tests import base -from keystoneauth1 import session as keystone_session -import mock -from novaclient.v2 import servers -from oslo_config import cfg class ServerProtectablePluginTest(base.TestCase): diff --git a/karbor/tests/unit/plugins/test_share_protectable_plugin.py b/karbor/tests/unit/plugins/test_share_protectable_plugin.py index abfd4b14..32e4c5b5 100644 --- a/karbor/tests/unit/plugins/test_share_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_share_protectable_plugin.py @@ -11,16 +11,16 @@ # under the License. import collections +from unittest import mock + +from manilaclient.v2 import shares +from oslo_config import cfg + from karbor.context import RequestContext from karbor.resource import Resource from karbor.services.protection.protectable_plugins.share \ import ShareProtectablePlugin - from karbor.tests import base -import mock - -from manilaclient.v2 import shares -from oslo_config import cfg class ShareProtectablePluginTest(base.TestCase): diff --git a/karbor/tests/unit/plugins/test_volume_protectable_plugin.py b/karbor/tests/unit/plugins/test_volume_protectable_plugin.py index 4addab44..3c948350 100644 --- a/karbor/tests/unit/plugins/test_volume_protectable_plugin.py +++ b/karbor/tests/unit/plugins/test_volume_protectable_plugin.py @@ -10,9 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + from cinderclient.v3 import volumes from collections import namedtuple -import mock from karbor.common import constants from karbor.context import RequestContext diff --git a/karbor/tests/unit/protection/fakes.py b/karbor/tests/unit/protection/fakes.py index 5350b5a4..9b9b4868 100644 --- a/karbor/tests/unit/protection/fakes.py +++ b/karbor/tests/unit/protection/fakes.py @@ -13,11 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. -import futurist -import mock +from unittest import mock +import futurist from oslo_config import cfg from oslo_log import log as logging +from taskflow import engines +from taskflow.patterns import graph_flow +from taskflow.patterns import linear_flow +from taskflow import task from karbor.resource import Resource from karbor.services.protection.bank_plugin import Bank @@ -28,11 +32,6 @@ from karbor.services.protection import protection_plugin from karbor.services.protection import provider from karbor.services.protection import resource_flow -from taskflow import engines -from taskflow.patterns import graph_flow -from taskflow.patterns import linear_flow -from taskflow import task - LOG = logging.getLogger(__name__) A = Resource(id='A', type='fake', name='fake') diff --git a/karbor/tests/unit/protection/test_checkpoint_collection.py b/karbor/tests/unit/protection/test_checkpoint_collection.py index 4232eb04..3ff7f47e 100644 --- a/karbor/tests/unit/protection/test_checkpoint_collection.py +++ b/karbor/tests/unit/protection/test_checkpoint_collection.py @@ -11,7 +11,7 @@ # under the License. from datetime import datetime -import mock +from unittest import mock from oslo_utils import timeutils diff --git a/karbor/tests/unit/protection/test_cinder_freezer_protection_plugin.py b/karbor/tests/unit/protection/test_cinder_freezer_protection_plugin.py index bdbfe85f..d9d50d8c 100644 --- a/karbor/tests/unit/protection/test_cinder_freezer_protection_plugin.py +++ b/karbor/tests/unit/protection/test_cinder_freezer_protection_plugin.py @@ -11,6 +11,10 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from oslo_config import fixture from karbor.common import constants from karbor.context import RequestContext @@ -23,11 +27,7 @@ from karbor.services.protection.protection_plugins.volume import \ volume_freezer_plugin_schemas from karbor.services.protection.protection_plugins.volume.\ volume_freezer_plugin import FreezerProtectionPlugin - from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_cinder_glance_plugin.py b/karbor/tests/unit/protection/test_cinder_glance_plugin.py index 636ee07b..68d7e855 100644 --- a/karbor/tests/unit/protection/test_cinder_glance_plugin.py +++ b/karbor/tests/unit/protection/test_cinder_glance_plugin.py @@ -11,6 +11,11 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor import exception @@ -24,9 +29,6 @@ from karbor.services.protection.protection_plugins.volume.\ from karbor.services.protection.protection_plugins.volume import \ volume_glance_plugin_schemas from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_cinder_protection_plugin.py b/karbor/tests/unit/protection/test_cinder_protection_plugin.py index d87bbf7c..22e51171 100644 --- a/karbor/tests/unit/protection/test_cinder_protection_plugin.py +++ b/karbor/tests/unit/protection/test_cinder_protection_plugin.py @@ -10,8 +10,13 @@ # License for the specific language governing permissions and limitations # under the License. -from cinderclient import exceptions as cinder_exc import collections +from unittest import mock + +from cinderclient import exceptions as cinder_exc +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor import exception @@ -24,9 +29,6 @@ from karbor.services.protection.protection_plugins.volume \ import volume_plugin_cinder_schemas as cinder_schemas from karbor.tests import base from karbor.tests.unit.protection import fakes -import mock -from oslo_config import cfg -from oslo_config import fixture ResourceNode = collections.namedtuple( diff --git a/karbor/tests/unit/protection/test_cinder_snapshot_protection_plugin.py b/karbor/tests/unit/protection/test_cinder_snapshot_protection_plugin.py index e1dc46dd..6a6caf0a 100644 --- a/karbor/tests/unit/protection/test_cinder_snapshot_protection_plugin.py +++ b/karbor/tests/unit/protection/test_cinder_snapshot_protection_plugin.py @@ -11,6 +11,11 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -23,9 +28,6 @@ from karbor.services.protection.protection_plugins. \ from karbor.services.protection.protection_plugins.volume \ import volume_snapshot_plugin_schemas from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_client_factory.py b/karbor/tests/unit/protection/test_client_factory.py index 516252b3..f9a746a8 100644 --- a/karbor/tests/unit/protection/test_client_factory.py +++ b/karbor/tests/unit/protection/test_client_factory.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from karbor.services.protection.client_factory import ClientFactory from karbor.tests import base diff --git a/karbor/tests/unit/protection/test_database_protection_plugin.py b/karbor/tests/unit/protection/test_database_protection_plugin.py index 89a09ff6..6073cd04 100644 --- a/karbor/tests/unit/protection/test_database_protection_plugin.py +++ b/karbor/tests/unit/protection/test_database_protection_plugin.py @@ -11,6 +11,11 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -18,16 +23,11 @@ from karbor.services.protection.bank_plugin import Bank from karbor.services.protection.bank_plugin import BankPlugin from karbor.services.protection.bank_plugin import BankSection from karbor.services.protection import client_factory - from karbor.services.protection.protection_plugins. \ database.database_backup_plugin import DatabaseBackupProtectionPlugin from karbor.services.protection.protection_plugins.database \ import database_backup_plugin_schemas - from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_glance_protection_plugin.py b/karbor/tests/unit/protection/test_glance_protection_plugin.py index 87032af5..1e7813bd 100644 --- a/karbor/tests/unit/protection/test_glance_protection_plugin.py +++ b/karbor/tests/unit/protection/test_glance_protection_plugin.py @@ -11,6 +11,12 @@ # under the License. import collections +from unittest import mock + +from keystoneauth1 import session as keystone_session +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -23,10 +29,6 @@ from karbor.services.protection.protection_plugins. \ from karbor.services.protection.protection_plugins.image \ import image_plugin_schemas from karbor.tests import base -from keystoneauth1 import session as keystone_session -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_manager.py b/karbor/tests/unit/protection/test_manager.py index f248342c..ed7d13bc 100644 --- a/karbor/tests/unit/protection/test_manager.py +++ b/karbor/tests/unit/protection/test_manager.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_config import cfg import oslo_messaging diff --git a/karbor/tests/unit/protection/test_manila_protection_plugin.py b/karbor/tests/unit/protection/test_manila_protection_plugin.py index 2b4ed01b..3e246693 100644 --- a/karbor/tests/unit/protection/test_manila_protection_plugin.py +++ b/karbor/tests/unit/protection/test_manila_protection_plugin.py @@ -11,6 +11,11 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -23,9 +28,6 @@ from karbor.services.protection.protection_plugins. \ from karbor.services.protection.protection_plugins.share \ import share_snapshot_plugin_schemas from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_neutron_protection_plugin.py b/karbor/tests/unit/protection/test_neutron_protection_plugin.py index 7d7723e9..3f3a97a4 100644 --- a/karbor/tests/unit/protection/test_neutron_protection_plugin.py +++ b/karbor/tests/unit/protection/test_neutron_protection_plugin.py @@ -11,6 +11,10 @@ # under the License. import collections +from unittest import mock + +from oslo_config import cfg + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -23,8 +27,6 @@ from karbor.services.protection.protection_plugins.network \ from karbor.services.protection.protection_plugins.network. \ neutron_protection_plugin import NeutronProtectionPlugin from karbor.tests import base -import mock -from oslo_config import cfg FakeNetworks = {'networks': [ {u'status': u'ACTIVE', diff --git a/karbor/tests/unit/protection/test_nova_protection_plugin.py b/karbor/tests/unit/protection/test_nova_protection_plugin.py index 19ff57b3..7b1a653c 100644 --- a/karbor/tests/unit/protection/test_nova_protection_plugin.py +++ b/karbor/tests/unit/protection/test_nova_protection_plugin.py @@ -11,7 +11,8 @@ # under the License. from collections import namedtuple -import mock +from unittest import mock + from oslo_config import cfg from karbor.common import constants diff --git a/karbor/tests/unit/protection/test_pod_protection_plugin.py b/karbor/tests/unit/protection/test_pod_protection_plugin.py index 7097a3c3..aa45d9e5 100644 --- a/karbor/tests/unit/protection/test_pod_protection_plugin.py +++ b/karbor/tests/unit/protection/test_pod_protection_plugin.py @@ -10,6 +10,15 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + +from kubernetes.client.models.v1_object_meta import V1ObjectMeta +from kubernetes.client.models.v1_pod import V1Pod +from kubernetes.client.models.v1_pod_spec import V1PodSpec +from kubernetes.client.models.v1_pod_status import V1PodStatus +from oslo_config import cfg +from oslo_config import fixture + from karbor.common import constants from karbor.context import RequestContext from karbor.resource import Resource @@ -18,21 +27,11 @@ from karbor.services.protection.bank_plugin import BankPlugin from karbor.services.protection.bank_plugin import BankSection from karbor.services.protection import client_factory from karbor.services.protection.clients import k8s - from karbor.services.protection.protection_plugins. \ pod.pod_protection_plugin import PodProtectionPlugin from karbor.services.protection.protection_plugins.pod \ import pod_plugin_schemas - -from kubernetes.client.models.v1_object_meta import V1ObjectMeta -from kubernetes.client.models.v1_pod import V1Pod -from kubernetes.client.models.v1_pod_spec import V1PodSpec -from kubernetes.client.models.v1_pod_status import V1PodStatus - from karbor.tests import base -import mock -from oslo_config import cfg -from oslo_config import fixture class FakeBankPlugin(BankPlugin): diff --git a/karbor/tests/unit/protection/test_provider.py b/karbor/tests/unit/protection/test_provider.py index 1741ce3a..2d449703 100755 --- a/karbor/tests/unit/protection/test_provider.py +++ b/karbor/tests/unit/protection/test_provider.py @@ -10,13 +10,14 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + +from oslo_config import cfg from karbor.resource import Resource from karbor.services.protection import provider from karbor.tests import base from karbor.tests.unit.protection import fakes -from oslo_config import cfg CONF = cfg.CONF diff --git a/karbor/tests/unit/protection/test_resource_flow.py b/karbor/tests/unit/protection/test_resource_flow.py index ba26b043..55ea1e5f 100644 --- a/karbor/tests/unit/protection/test_resource_flow.py +++ b/karbor/tests/unit/protection/test_resource_flow.py @@ -11,7 +11,9 @@ # under the License. from functools import partial -import mock +from unittest import mock + +from oslo_config import cfg from karbor.common import constants from karbor.resource import Resource @@ -20,7 +22,6 @@ from karbor.services.protection import graph from karbor.services.protection import resource_flow from karbor.tests import base from karbor.tests.unit.protection import fakes -from oslo_config import cfg CONF = cfg.CONF diff --git a/karbor/tests/unit/protection/test_s3_bank_plugin.py b/karbor/tests/unit/protection/test_s3_bank_plugin.py index 1a8d0f8d..ad9e9425 100644 --- a/karbor/tests/unit/protection/test_s3_bank_plugin.py +++ b/karbor/tests/unit/protection/test_s3_bank_plugin.py @@ -10,14 +10,16 @@ # License for the specific language governing permissions and limitations # under the License. +import math +import time +from unittest import mock + +from oslo_config import cfg +from oslo_utils import importutils + from karbor.services.protection.clients import s3 from karbor.tests import base from karbor.tests.unit.protection.fake_s3_client import FakeS3Client -import math -import mock -from oslo_config import cfg -from oslo_utils import importutils -import time CONF = cfg.CONF diff --git a/karbor/tests/unit/protection/test_swift_bank_plugin.py b/karbor/tests/unit/protection/test_swift_bank_plugin.py index 03c24d4b..f3eedaaf 100644 --- a/karbor/tests/unit/protection/test_swift_bank_plugin.py +++ b/karbor/tests/unit/protection/test_swift_bank_plugin.py @@ -10,15 +10,17 @@ # License for the specific language governing permissions and limitations # under the License. +import math +import os +import time +from unittest import mock + +from oslo_config import cfg +from oslo_utils import importutils + from karbor.services.protection.clients import swift from karbor.tests import base from karbor.tests.unit.protection.fake_swift_client import FakeSwiftClient -import math -import mock -import os -from oslo_config import cfg -from oslo_utils import importutils -import time CONF = cfg.CONF diff --git a/karbor/tests/unit/test_exception.py b/karbor/tests/unit/test_exception.py index fbe2d6ae..7d85662c 100644 --- a/karbor/tests/unit/test_exception.py +++ b/karbor/tests/unit/test_exception.py @@ -10,15 +10,15 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + +import six from six.moves import http_client +import webob.util from karbor import exception from karbor.tests import base -import mock -import six -import webob.util - class KarborExceptionTestCase(base.TestCase): def test_default_error_msg(self): diff --git a/karbor/tests/unit/test_rpc.py b/karbor/tests/unit/test_rpc.py index 5422b505..e7c3e0c8 100644 --- a/karbor/tests/unit/test_rpc.py +++ b/karbor/tests/unit/test_rpc.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from oslo_config import cfg diff --git a/karbor/tests/unit/test_service.py b/karbor/tests/unit/test_service.py index c7b091a6..7e15a736 100644 --- a/karbor/tests/unit/test_service.py +++ b/karbor/tests/unit/test_service.py @@ -14,7 +14,8 @@ Unit Tests for remote procedure calls using queue """ -import mock +from unittest import mock + from oslo_concurrency import processutils from oslo_config import cfg from oslo_db import exception as db_exc