From 751027858be2b7a3edae8ba775969fd2d57e4ca0 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Sat, 18 Apr 2020 12:01:38 -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: I6cdd4c35a52a014ba3c4dfe4cc2bd4d670c96bc3 Signed-off-by: Sean McGinnis --- watcher/tests/api/v1/test_audit_templates.py | 4 ++-- watcher/tests/applier/actions/test_change_node_power_state.py | 3 ++- .../tests/applier/actions/test_change_nova_service_state.py | 3 ++- watcher/tests/applier/actions/test_migration.py | 3 ++- watcher/tests/applier/actions/test_volume_migration.py | 3 ++- watcher/tests/cmd/test_applier.py | 4 ++-- .../decision_engine/messaging/test_data_model_endpoint.py | 1 - 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/watcher/tests/api/v1/test_audit_templates.py b/watcher/tests/api/v1/test_audit_templates.py index 91d7c2885..61526a609 100644 --- a/watcher/tests/api/v1/test_audit_templates.py +++ b/watcher/tests/api/v1/test_audit_templates.py @@ -14,11 +14,11 @@ import datetime import itertools from unittest import mock from urllib import parse as urlparse -from webtest.app import AppError from oslo_config import cfg from oslo_serialization import jsonutils from oslo_utils import timeutils +import webtest.app as webtest_app from wsme import types as wtypes from watcher.api.controllers.v1 import audit_template as api_audit_template @@ -574,7 +574,7 @@ class TestPost(FunctionalTestWithSetup): audit_template_dict = post_get_test_audit_template( goal=self.fake_goal1.uuid, strategy=self.fake_strategy1.uuid, scope=scope) - with self.assertRaisesRegex(AppError, + with self.assertRaisesRegex(webtest_app.AppError, "be included and excluded together"): self.post_json('/audit_templates', audit_template_dict) diff --git a/watcher/tests/applier/actions/test_change_node_power_state.py b/watcher/tests/applier/actions/test_change_node_power_state.py index a3b045c8f..aeadeeb10 100644 --- a/watcher/tests/applier/actions/test_change_node_power_state.py +++ b/watcher/tests/applier/actions/test_change_node_power_state.py @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import jsonschema from unittest import mock +import jsonschema + from watcher.applier.actions import base as baction from watcher.applier.actions import change_node_power_state from watcher.common import clients diff --git a/watcher/tests/applier/actions/test_change_nova_service_state.py b/watcher/tests/applier/actions/test_change_nova_service_state.py index 6188e5932..192f871a8 100644 --- a/watcher/tests/applier/actions/test_change_nova_service_state.py +++ b/watcher/tests/applier/actions/test_change_nova_service_state.py @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import jsonschema from unittest import mock +import jsonschema + from watcher.applier.actions import base as baction from watcher.applier.actions import change_nova_service_state from watcher.common import clients diff --git a/watcher/tests/applier/actions/test_migration.py b/watcher/tests/applier/actions/test_migration.py index 578e1d713..ec2c38c5a 100644 --- a/watcher/tests/applier/actions/test_migration.py +++ b/watcher/tests/applier/actions/test_migration.py @@ -13,9 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import jsonschema from unittest import mock +import jsonschema + from watcher.applier.actions import base as baction from watcher.applier.actions import migration from watcher.common import clients diff --git a/watcher/tests/applier/actions/test_volume_migration.py b/watcher/tests/applier/actions/test_volume_migration.py index aa0081d2b..ae77e5578 100644 --- a/watcher/tests/applier/actions/test_volume_migration.py +++ b/watcher/tests/applier/actions/test_volume_migration.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import jsonschema from unittest import mock +import jsonschema + from watcher.applier.actions import base as baction from watcher.applier.actions import volume_migration from watcher.common import cinder_helper diff --git a/watcher/tests/cmd/test_applier.py b/watcher/tests/cmd/test_applier.py index 6fca8fa62..c865b4a57 100644 --- a/watcher/tests/cmd/test_applier.py +++ b/watcher/tests/cmd/test_applier.py @@ -19,10 +19,10 @@ from unittest import mock from oslo_config import cfg from oslo_service import service -from watcher.applier import sync -from watcher.common import service as watcher_service +from watcher.applier import sync from watcher.cmd import applier +from watcher.common import service as watcher_service from watcher.tests import base diff --git a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py index b0e375b4e..9c63b5bff 100644 --- a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py +++ b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py @@ -13,7 +13,6 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. - import unittest from unittest import mock