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: I6245a207ec65df0ef11a798b4cffe3157abccb73
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Co-Authored-By: Spyros Trigazis <spyridon.trigazis@cern.ch>
This commit is contained in:
Sean McGinnis 2020-04-18 11:54:00 -05:00 committed by Spyros Trigazis
parent dc01c99c70
commit 45fd25c572
71 changed files with 95 additions and 72 deletions

View File

@ -15,9 +15,9 @@
import copy
import os
from unittest import mock
import fixtures
import mock
from oslo_config import cfg
from oslo_log import log
import oslo_messaging

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import time
from unittest import mock
from oslo_service import loopingcall

View File

@ -18,8 +18,9 @@
# https://bugs.launchpad.net/ironic/+bug/1255115.
# NOTE(deva): import auth_token so we can override a config option
from unittest import mock
from keystonemiddleware import auth_token # noqa
import mock
from oslo_config import cfg
import pecan
import pecan.testing

View File

@ -10,7 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from webob import exc
from magnum.api.controllers import base

View File

@ -10,8 +10,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import fixtures
import mock
from oslo_config import cfg
from webob import exc as webob_exc

View File

@ -11,8 +11,8 @@
# limitations under the License.
import datetime
from unittest import mock
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils

View File

@ -11,8 +11,8 @@
# limitations under the License.
import datetime
from unittest import mock
import mock
from oslo_utils import timeutils
from oslo_utils import uuidutils
from six.moves.urllib import parse as urlparse

View File

@ -10,7 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils
from magnum.api.controllers.v1 import certificate as api_cert

View File

@ -11,8 +11,8 @@
# limitations under the License.
import datetime
from unittest import mock
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from magnum.conductor import api as rpcapi
import magnum.conf

View File

@ -11,8 +11,8 @@
# limitations under the License.
import datetime
from unittest import mock
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils

View File

@ -11,7 +11,7 @@
# under the License.
import datetime
import mock
from unittest import mock
from oslo_config import cfg
from oslo_utils import uuidutils

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from magnum.api.controllers.v1 import magnum_services as mservice
from magnum.api import servicegroup

View File

@ -14,7 +14,7 @@
# under the License.
import datetime
import mock
from unittest import mock
from oslo_utils import timeutils
from oslo_utils import uuidutils

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from keystoneauth1 import exceptions as ka_exception

View File

@ -10,7 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from webtest.app import AppError

View File

@ -12,9 +12,10 @@
# 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 unittest import mock
from oslo_utils import uuidutils
import mock
import six
import webtest
import wsme

View File

@ -14,7 +14,8 @@
# under the License.
import jsonpatch
import mock
from unittest import mock
from oslo_utils import uuidutils
import wsme

View File

@ -14,8 +14,8 @@
from glanceclient import exc as glance_exception
import mock
from novaclient import exceptions as nova_exc
from unittest import mock
from magnum.api import attr_validator
from magnum.common import exception

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.api import expose
from magnum.tests import base

View File

@ -13,9 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import six
import mock
from oslo_config import cfg
import oslo_messaging as messaging

View File

@ -11,8 +11,8 @@
# limitations under the License.
import datetime
from unittest import mock
import mock
from oslo_utils import timeutils
import pytz

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from six.moves import reload_module
from magnum.api import validation as v

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_concurrency import processutils

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from oslo_concurrency import processutils

View File

@ -12,7 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
import six
from magnum.cmd import db_manage

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from magnum.cmd import driver_manage
from magnum.tests import base

View File

@ -12,12 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import uuid
from barbicanclient.v1 import client as barbican_client
from barbicanclient.v1 import containers
from barbicanclient.v1 import secrets
import mock
from mock import patch
from magnum.common.cert_manager import barbican_cert_manager as bcm

View File

@ -12,7 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_config import fixture
from magnum.common import cert_manager

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
from unittest import mock
import mock
from oslo_config import cfg
from oslo_config import fixture as oslo_fixture

View File

@ -11,7 +11,7 @@
# 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 unittest import mock
from magnum.common.cert_manager import x509keypair_cert_manager as x509_cm
from magnum.common import context

View File

@ -13,9 +13,9 @@
from barbicanclient.v1 import client as barbicanclient
from glanceclient import client as glanceclient
from heatclient import client as heatclient
import mock
from neutronclient.v2_0 import client as neutronclient
from novaclient import client as novaclient
from unittest import mock
from magnum.common import clients
from magnum.common import exception

View File

@ -13,7 +13,7 @@
# under the License.
import docker
import mock
from unittest import mock
from magnum.common import docker_utils
import magnum.conf

View File

@ -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 fixture
from keystoneauth1 import exceptions as ka_exception

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from magnum.common import exception
from magnum.common import neutron

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from magnum.common import exception
from magnum.common import octavia

View File

@ -14,7 +14,7 @@
# under the License.
import inspect
import mock
from unittest import mock
from oslo_config import cfg
from oslo_utils import importutils

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
import oslo_messaging as messaging
from oslo_messaging.rpc import dispatcher
from oslo_serialization import jsonutils

View File

@ -11,7 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_log import log as logging

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from oslo_config import cfg
from magnum.common import urlfetch

View File

@ -18,8 +18,8 @@ import os
import os.path
import shutil
import tempfile
from unittest import mock
import mock
from oslo_concurrency import processutils
from oslo_utils import netutils

View File

@ -14,7 +14,7 @@
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
import mock
from unittest import mock
from magnum.common.x509 import operations
from magnum.tests import base

View File

@ -18,7 +18,8 @@ from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography import x509 as c_x509
from cryptography.x509.oid import NameOID
import mock
from unittest import mock
import six
from magnum.common import exception

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.common import exception
from magnum.conductor.handlers.common import cert_manager

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from magnum.common import exception
from magnum.conductor.handlers.common import trust_manager

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.conductor.handlers import ca_conductor
from magnum.tests import base

View File

@ -14,10 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import six
from heatclient import exc
import mock
from mock import patch
from oslo_service import loopingcall
from pycadf import cadftaxonomy as taxonomy

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
import magnum.conf
from magnum.drivers.k8s_coreos_v1 import driver as k8s_coreos_dr

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from magnum.drivers.heat import driver as heat_driver
from magnum.drivers.mesos_ubuntu_v1 import driver as mesos_dr

View File

@ -13,8 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from heatclient import exc

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
import magnum.conf
from magnum.drivers.heat import driver as heat_driver

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from taskflow import engines
from taskflow.patterns import linear_flow
from unittest import mock
from magnum.conductor.tasks import heat_tasks
from magnum.tests import base

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.tests import base

View File

@ -14,8 +14,8 @@
# limitations under the License.
from collections import namedtuple
from unittest import mock
import mock
from oslo_serialization import jsonutils
from magnum.common import exception

View File

@ -14,8 +14,8 @@ Unit Tests for :py:class:`magnum.conductor.rpcapi.API`.
"""
import copy
from unittest import mock
import mock
from magnum.conductor import api as conductor_rpcapi
from magnum import objects

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.common import exception
from magnum.conductor import scale_manager

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from magnum.conductor import utils
from magnum import objects

View File

@ -13,7 +13,8 @@
# under the License.
import collections
import mock
from unittest import mock
from oslo_config import cfg
import six

View File

@ -10,10 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from mock import patch
from unittest import mock
from heatclient import exc as heatexc
from oslo_utils import uuidutils
import magnum.conf
from magnum.drivers.heat import driver as heat_driver
@ -87,7 +88,8 @@ class TestHeatPoller(base.TestCase):
if default_stack_status is None:
default_stack_status = cluster_status.CREATE_COMPLETE
cluster = mock.MagicMock(nodegroups=list())
cluster = mock.MagicMock(nodegroups=list(),
uuid=uuidutils.generate_uuid())
def_worker = self._create_nodegroup(cluster, 'worker_ng', 'stack1',
name='worker_ng', role='worker',

View File

@ -13,8 +13,9 @@
# under the License.
import abc
import mock
from neutronclient.common import exceptions as n_exception
from unittest import mock
import six
from magnum.common import exception

View File

@ -13,7 +13,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 testtools.matchers import HasLength

View File

@ -13,7 +13,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 testtools.matchers import HasLength

View File

@ -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 testtools.matchers import HasLength

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum import objects
from magnum.tests.unit.db import base

View File

@ -13,7 +13,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 testtools.matchers import HasLength

View File

@ -14,8 +14,8 @@
import datetime
import gettext
from unittest import mock
import mock
from oslo_versionedobjects import exception as object_exception
from oslo_versionedobjects import fields
from oslo_versionedobjects import fixture

View File

@ -13,7 +13,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 testtools.matchers import HasLength

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from oslo_utils import uuidutils

View File

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from magnum.common.rpc_service import CONF
from magnum import objects

View File

@ -13,8 +13,8 @@
# under the License.
import textwrap
from unittest import mock
import mock
import pycodestyle
from magnum.hacking import checks

View File

@ -11,7 +11,6 @@ coverage!=4.4,>=4.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0,<3.1.0 # Apache-2.0
mock>=2.0.0 # BSD
oslotest>=3.2.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0