Merge "Use unittest.mock instead of third party mock"

This commit is contained in:
Zuul 2020-05-03 22:23:59 +00:00 committed by Gerrit Code Review
commit 59572992a2
71 changed files with 95 additions and 72 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,9 +12,10 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
import mock
import six import six
import webtest import webtest
import wsme import wsme

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,12 +12,12 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from unittest import mock
import uuid import uuid
from barbicanclient.v1 import client as barbican_client from barbicanclient.v1 import client as barbican_client
from barbicanclient.v1 import containers from barbicanclient.v1 import containers
from barbicanclient.v1 import secrets from barbicanclient.v1 import secrets
import mock
from mock import patch from mock import patch
from magnum.common.cert_manager import barbican_cert_manager as bcm 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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_config import fixture from oslo_config import fixture
from magnum.common import cert_manager from magnum.common import cert_manager

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import os import os
from unittest import mock
import mock
from oslo_config import cfg from oslo_config import cfg
from oslo_config import fixture as oslo_fixture 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 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from magnum.common.cert_manager import x509keypair_cert_manager as x509_cm from magnum.common.cert_manager import x509keypair_cert_manager as x509_cm
from magnum.common import context from magnum.common import context

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@
from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
import mock from unittest import mock
from magnum.common.x509 import operations from magnum.common.x509 import operations
from magnum.tests import base 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.hazmat.primitives import serialization
from cryptography import x509 as c_x509 from cryptography import x509 as c_x509
from cryptography.x509.oid import NameOID from cryptography.x509.oid import NameOID
import mock from unittest import mock
import six import six
from magnum.common import exception from magnum.common import exception

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
from mock import patch from mock import patch
from unittest import mock
import magnum.conf import magnum.conf
from magnum.drivers.k8s_coreos_v1 import driver as k8s_coreos_dr 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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
from mock import patch from mock import patch
from unittest import mock
from magnum.drivers.heat import driver as heat_driver from magnum.drivers.heat import driver as heat_driver
from magnum.drivers.mesos_ubuntu_v1 import driver as mesos_dr 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 # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock
from mock import patch from mock import patch
from unittest import mock
from heatclient import exc from heatclient import exc

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

@ -10,7 +10,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

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

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

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

View File

@ -13,7 +13,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
from testtools.matchers import HasLength from testtools.matchers import HasLength

View File

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

View File

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

View File

@ -13,8 +13,8 @@
# under the License. # under the License.
import textwrap import textwrap
from unittest import mock
import mock
import pycodestyle import pycodestyle
from magnum.hacking import checks 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 doc8>=0.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0,<3.1.0 # Apache-2.0 hacking>=3.0,<3.1.0 # Apache-2.0
mock>=2.0.0 # BSD
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0 osprofiler>=1.4.0 # Apache-2.0
os-testr>=1.0.0 # Apache-2.0 os-testr>=1.0.0 # Apache-2.0