Use unittest.mock instead of mock

The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: I7b97fab683e45118327b93c776f8c487feab7374
This commit is contained in:
Hervé Beraud 2020-06-09 12:18:35 +02:00
parent 4bf6c496bb
commit 4b654a840f
53 changed files with 99 additions and 100 deletions

View File

@ -56,7 +56,6 @@ lxml==3.4.1
Mako==1.0.7 Mako==1.0.7
MarkupSafe==1.0 MarkupSafe==1.0
mccabe==0.4.0 mccabe==0.4.0
mock==2.0.0
monotonic==1.4 monotonic==1.4
mox3==0.25.0 mox3==0.25.0
msgpack==0.5.6 msgpack==0.5.6

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
from hashlib import md5 from hashlib import md5
from mock import MagicMock, patch from unittest.mock import MagicMock, patch
import json import json
import os import os
import socket import socket

View File

@ -18,7 +18,7 @@ Tests dealing with HTTP rate-limiting.
""" """
from mock import Mock, MagicMock, patch from unittest.mock import Mock, MagicMock, patch
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import six import six
from six.moves import http_client from six.moves import http_client

View File

@ -13,7 +13,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.
from mock import Mock from unittest.mock import Mock
import webob import webob
from trove.common import cfg from trove.common import cfg

View File

@ -13,9 +13,9 @@
import datetime import datetime
from mock import DEFAULT from unittest.mock import DEFAULT
from mock import MagicMock from unittest.mock import MagicMock
from mock import patch from unittest.mock import patch
from swiftclient.client import ClientException from swiftclient.client import ClientException
from trove.backup import models from trove.backup import models

View File

@ -13,10 +13,10 @@
# 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 mock import ANY from unittest.mock import ANY
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.cluster import models from trove.cluster import models
from trove.common.strategies.cluster.experimental.cassandra.api \ from trove.common.strategies.cluster.experimental.cassandra.api \

View File

@ -15,8 +15,8 @@
import uuid import uuid
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.cluster.models import Cluster from trove.cluster.models import Cluster
from trove.cluster.models import ClusterTasks from trove.cluster.models import ClusterTasks
from trove.cluster.models import DBCluster from trove.cluster.models import DBCluster

View File

@ -15,9 +15,9 @@
# #
import jsonschema import jsonschema
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from testtools.matchers import Is, Equals from testtools.matchers import Is, Equals
from trove.cluster import models from trove.cluster import models
from trove.cluster.models import Cluster, DBCluster from trove.cluster.models import Cluster, DBCluster

View File

@ -13,7 +13,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.
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.cluster import models from trove.cluster import models
from trove.common.strategies.cluster.experimental.mongodb.api import ( from trove.common.strategies.cluster.experimental.mongodb.api import (

View File

@ -13,9 +13,9 @@
import jsonschema import jsonschema
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from testtools.matchers import Is, Equals from testtools.matchers import Is, Equals
from trove.cluster import models from trove.cluster import models
from trove.cluster.models import Cluster from trove.cluster.models import Cluster

View File

@ -13,9 +13,9 @@
import jsonschema import jsonschema
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from testtools.matchers import Is, Equals from testtools.matchers import Is, Equals
from trove.cluster import models from trove.cluster import models
from trove.cluster.models import Cluster from trove.cluster.models import Cluster

View File

@ -13,9 +13,9 @@
import jsonschema import jsonschema
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from testtools.matchers import Is, Equals from testtools.matchers import Is, Equals
from trove.cluster import models from trove.cluster import models
from trove.cluster.models import Cluster from trove.cluster.models import Cluster

View File

@ -14,9 +14,9 @@
# under the License. # under the License.
# #
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.cluster.views import ClusterInstanceDetailView from trove.cluster.views import ClusterInstanceDetailView
from trove.cluster.views import ClusterView from trove.cluster.views import ClusterView

View File

@ -13,8 +13,8 @@
import uuid import uuid
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions

View File

@ -13,13 +13,13 @@
# 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 mock import ANY from unittest.mock import ANY
from mock import call from unittest.mock import call
from mock import DEFAULT from unittest.mock import DEFAULT
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from mock import PropertyMock from unittest.mock import PropertyMock
from neutronclient.common import exceptions as neutron_exceptions from neutronclient.common import exceptions as neutron_exceptions

View File

@ -13,8 +13,8 @@
import uuid import uuid
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
from trove.cluster.models import Cluster from trove.cluster.models import Cluster
from trove.cluster.models import ClusterTasks from trove.cluster.models import ClusterTasks

View File

@ -13,8 +13,8 @@
import uuid import uuid
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
from trove.cluster.models import Cluster from trove.cluster.models import Cluster
from trove.cluster.models import ClusterTasks from trove.cluster.models import ClusterTasks

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.
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from oslo_upgradecheck.upgradecheck import Code from oslo_upgradecheck.upgradecheck import Code
from trove.cmd import status from trove.cmd import status

View File

@ -13,7 +13,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.
# #
from mock import Mock from unittest.mock import Mock
from testtools.matchers import Equals, Is from testtools.matchers import Equals, Is
from trove.common import context from trove.common import context

View File

@ -13,7 +13,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.
# #
from mock import Mock, patch from unittest.mock import Mock, patch
from oslo_utils import timeutils from oslo_utils import timeutils

View File

@ -16,7 +16,7 @@
# under the License. # under the License.
# #
from mock import Mock from unittest.mock import Mock
from trove.common import pagination from trove.common import pagination
from trove.tests.unittests import trove_testtools from trove.tests.unittests import trove_testtools

View File

@ -13,9 +13,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.
from mock import MagicMock from unittest.mock import MagicMock
from mock import NonCallableMock from unittest.mock import NonCallableMock
from mock import patch from unittest.mock import patch
from trove.common import exception as trove_exceptions from trove.common import exception as trove_exceptions
from trove.common import policy as trove_policy from trove.common import policy as trove_policy

View File

@ -15,7 +15,7 @@
# #
import copy import copy
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.common import server_group as srv_grp from trove.common import server_group as srv_grp
from trove.tests.unittests import trove_testtools from trove.tests.unittests import trove_testtools

View File

@ -11,7 +11,7 @@
# limitations under the License. # limitations under the License.
import re import re
from mock import Mock from unittest.mock import Mock
from trove.common import template from trove.common import template
from trove.datastore.models import DatastoreVersion from trove.datastore.models import DatastoreVersion

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
# #
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from testtools import ExpectedException from testtools import ExpectedException
from trove.common import exception from trove.common import exception

View File

@ -13,7 +13,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.
# #
from mock import Mock, patch from unittest.mock import Mock, patch
from testtools.matchers import Equals, Is, Not from testtools.matchers import Equals, Is, Not
import webob.exc import webob.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.
from mock import MagicMock from unittest.mock import MagicMock
from mock import patch from unittest.mock import patch
from oslo_service import service as os_service from oslo_service import service as os_service
from trove.cmd import common as common_cmd from trove.cmd import common as common_cmd

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.
from mock import patch from unittest.mock import patch
from oslo_utils import timeutils from oslo_utils import timeutils
from trove.backup import models as bkup_models from trove.backup import models as bkup_models

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
import jsonschema import jsonschema
from mock import MagicMock from unittest.mock import MagicMock
from trove.common import configurations from trove.common import configurations
from trove.common.exception import UnprocessableEntity from trove.common.exception import UnprocessableEntity

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.
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.common import exception from trove.common import exception
from trove.datastore import models as datastore_models from trove.datastore import models as datastore_models

View File

@ -13,9 +13,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.
# #
from mock import call from unittest.mock import call
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from sqlalchemy.engine import reflection from sqlalchemy.engine import reflection
from sqlalchemy.schema import Column from sqlalchemy.schema import Column

View File

@ -14,8 +14,8 @@
import base64 import base64
import hashlib import hashlib
from mock import MagicMock from unittest.mock import MagicMock
from mock import patch from unittest.mock import patch
import six import six
from trove.common import exception from trove.common import exception

View File

@ -14,8 +14,8 @@
# under the License. # under the License.
# #
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from oslo_config.cfg import NoSuchOptError from oslo_config.cfg import NoSuchOptError
from trove.common import exception from trove.common import exception

View File

@ -15,7 +15,7 @@
# #
import uuid import uuid
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.common import exception from trove.common import exception
from trove.datastore import models as datastore_models from trove.datastore import models as datastore_models

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.flavor.views import FlavorView from trove.flavor.views import FlavorView
from trove.tests.unittests import trove_testtools from trove.tests.unittests import trove_testtools

View File

@ -14,10 +14,10 @@
# under the License. # under the License.
# #
import copy import copy
from unittest.mock import Mock
import uuid import uuid
import jsonschema import jsonschema
from mock import Mock
from testtools.matchers import Equals from testtools.matchers import Equals
from testtools.matchers import Is from testtools.matchers import Is
from testtools.testcase import skip from testtools.testcase import skip

View File

@ -11,8 +11,8 @@
# 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 mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
import uuid import uuid
from trove.backup import models as backup_models from trove.backup import models as backup_models

View File

@ -13,7 +13,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.
# #
from mock import Mock from unittest.mock import Mock
from trove.common import cfg from trove.common import cfg
from trove.instance.views import InstanceDetailView from trove.instance.views import InstanceDetailView
from trove.instance.views import InstanceView from trove.instance.views import InstanceView

View File

@ -11,7 +11,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.
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.common import exception from trove.common import exception
from trove.extensions.mgmt.clusters.models import MgmtCluster from trove.extensions.mgmt.clusters.models import MgmtCluster

View File

@ -14,7 +14,7 @@
import jsonschema import jsonschema
from mock import Mock, patch, MagicMock, PropertyMock from unittest.mock import Mock, patch, MagicMock, PropertyMock
from testtools.matchers import Is, Equals from testtools.matchers import Is, Equals
from trove.common import clients from trove.common import clients

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.
from mock import Mock, patch from unittest.mock import Mock, patch
from glanceclient import exc as glance_exceptions from glanceclient import exc as glance_exceptions
from trove.common import clients from trove.common import clients

View File

@ -18,9 +18,9 @@ from testtools.matchers import Is
from testtools.matchers import Not from testtools.matchers import Not
import uuid import uuid
from mock import ANY from unittest.mock import ANY
from mock import MagicMock from unittest.mock import MagicMock
from mock import patch from unittest.mock import patch
from novaclient.client import Client from novaclient.client import Client
from novaclient.v2.flavors import Flavor from novaclient.v2.flavors import Flavor
from novaclient.v2.flavors import FlavorManager from novaclient.v2.flavors import FlavorManager

View File

@ -15,7 +15,7 @@
# #
import copy import copy
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.common import crypto_utils from trove.common import crypto_utils
from trove.common import exception from trove.common import exception

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
from mock import Mock, patch from unittest.mock import Mock, patch
from trove.datastore import models from trove.datastore import models
from trove.module.views import DetailedModuleView from trove.module.views import DetailedModuleView
from trove.tests.unittests import trove_testtools from trove.tests.unittests import trove_testtools

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.
from mock import Mock, MagicMock, patch from unittest.mock import Mock, MagicMock, patch
from testtools import skipIf from testtools import skipIf
from trove.common import cfg from trove.common import cfg

View File

@ -14,8 +14,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.
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from unittest import mock from unittest import mock
from trove.common import context from trove.common import context

View File

@ -15,9 +15,9 @@
import datetime import datetime
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.cluster.models import ClusterTasks as ClusterTaskStatus from trove.cluster.models import ClusterTasks as ClusterTaskStatus
from trove.cluster.models import DBCluster from trove.cluster.models import DBCluster

View File

@ -13,8 +13,8 @@
import datetime import datetime
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove.cluster.models import ClusterTasks as ClusterTaskStatus from trove.cluster.models import ClusterTasks as ClusterTaskStatus
from trove.cluster.models import DBCluster from trove.cluster.models import DBCluster

View File

@ -14,7 +14,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.
from mock import MagicMock, Mock, patch, PropertyMock from unittest.mock import MagicMock, Mock, patch, PropertyMock
from proboscis.asserts import assert_equal from proboscis.asserts import assert_equal
from trove.backup.models import Backup from trove.backup.models import Backup

View File

@ -18,11 +18,11 @@ from unittest import mock
from cinderclient import exceptions as cinder_exceptions from cinderclient import exceptions as cinder_exceptions
from cinderclient.v2 import volumes as cinderclient_volumes from cinderclient.v2 import volumes as cinderclient_volumes
import cinderclient.v2.client as cinderclient import cinderclient.v2.client as cinderclient
from mock import call from unittest.mock import call
from mock import MagicMock from unittest.mock import MagicMock
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from mock import PropertyMock from unittest.mock import PropertyMock
import neutronclient.v2_0.client as neutronclient import neutronclient.v2_0.client as neutronclient
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
import novaclient.v2.flavors import novaclient.v2.flavors

View File

@ -13,8 +13,8 @@
import datetime import datetime
from mock import Mock from unittest.mock import Mock
from mock import patch from unittest.mock import patch
from trove import rpc from trove import rpc
from trove.cluster.models import ClusterTasks as ClusterTaskStatus from trove.cluster.models import ClusterTasks as ClusterTaskStatus

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
# #
import jsonschema import jsonschema
from mock import Mock, MagicMock, patch from unittest.mock import Mock, MagicMock, patch
from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender
from trove.extensions.mgmt.upgrade.service import UpgradeController from trove.extensions.mgmt.upgrade.service import UpgradeController

View File

@ -13,7 +13,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.
# #
from mock import patch from unittest.mock import patch
from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender from trove.extensions.mgmt.upgrade.models import UpgradeMessageSender
from trove import rpc from trove import rpc
from trove.tests.unittests import trove_testtools from trove.tests.unittests import trove_testtools