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: I130c03e12ddc53ce7ced728a43b10b142f7b066f
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Co-Authored-By: Hiroo Kitamura <hiroo.kitamura@ntt-at.co.jp>
changes/20/721020/8
Sean McGinnis 3 years ago committed by Hiroo Kitamura
parent 264ef947c3
commit 41a21bc807
  1. 1
      lower-constraints.txt
  2. 4
      tacker/db/migration/cli.py
  3. 2
      tacker/tests/base.py
  4. 2
      tacker/tests/unit/agent/linux/test_utils.py
  5. 3
      tacker/tests/unit/api/test_v2_extension.py
  6. 3
      tacker/tests/unit/api/v1/test_resource.py
  7. 2
      tacker/tests/unit/api/v1/test_resource_helper.py
  8. 2
      tacker/tests/unit/api/v1/test_router.py
  9. 3
      tacker/tests/unit/api/v1/test_vim.py
  10. 2
      tacker/tests/unit/api/v2/test_api_v2.py
  11. 3
      tacker/tests/unit/base.py
  12. 2
      tacker/tests/unit/common/test_config.py
  13. 2
      tacker/tests/unit/common/test_csar_utils.py
  14. 2
      tacker/tests/unit/common/test_log.py
  15. 2
      tacker/tests/unit/conductor/conductorrpc/test_vnf_pkgm_rpc.py
  16. 4
      tacker/tests/unit/conductor/test_conductor_server.py
  17. 2
      tacker/tests/unit/db/common_services/test_common_services_db_plugin.py
  18. 2
      tacker/tests/unit/db/test_db_migration.py
  19. 2
      tacker/tests/unit/db/test_db_purge_delete.py
  20. 2
      tacker/tests/unit/extensions/test_common_services.py
  21. 2
      tacker/tests/unit/glance_store/test_store.py
  22. 3
      tacker/tests/unit/nfvo/drivers/vim/test_kubernetes_driver.py
  23. 2
      tacker/tests/unit/nfvo/drivers/vim/test_openstack_driver.py
  24. 2
      tacker/tests/unit/nfvo/drivers/vnffg/sfc_drivers/networking-sfc/test_n_sfc.py
  25. 6
      tacker/tests/unit/nfvo/test_nfvo_plugin.py
  26. 2
      tacker/tests/unit/objects/test_vnf_deployment_flavour.py
  27. 6
      tacker/tests/unit/objects/test_vnf_instance.py
  28. 3
      tacker/tests/unit/objects/test_vnf_package.py
  29. 2
      tacker/tests/unit/objects/test_vnf_resource.py
  30. 3
      tacker/tests/unit/test_alarm_receiver.py
  31. 3
      tacker/tests/unit/test_context.py
  32. 3
      tacker/tests/unit/test_policy.py
  33. 3
      tacker/tests/unit/test_wsgi.py
  34. 2
      tacker/tests/unit/tests/test_post_mortem_debug.py
  35. 2
      tacker/tests/unit/vnflcm/test_controller.py
  36. 3
      tacker/tests/unit/vnflcm/test_vnflcm_driver.py
  37. 3
      tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack.py
  38. 7
      tacker/tests/unit/vnfm/infra_drivers/openstack/test_openstack_driver.py
  39. 2
      tacker/tests/unit/vnfm/infra_drivers/openstack/test_vdu.py
  40. 3
      tacker/tests/unit/vnfm/monitor_drivers/http_ping/test_http_ping.py
  41. 2
      tacker/tests/unit/vnfm/monitor_drivers/ping/test_ping.py
  42. 2
      tacker/tests/unit/vnfm/monitor_drivers/zabbix/test_zabbix.py
  43. 2
      tacker/tests/unit/vnfm/policy_actions/autoscaling/test_autoscaling.py
  44. 2
      tacker/tests/unit/vnfm/policy_actions/log/test_log.py
  45. 2
      tacker/tests/unit/vnfm/policy_actions/respawn/test_respawn.py
  46. 2
      tacker/tests/unit/vnfm/policy_actions/vdu_autoheal/test_vdu_autoheal.py
  47. 4
      tacker/tests/unit/vnfm/test_k8s_plugin.py
  48. 3
      tacker/tests/unit/vnfm/test_monitor.py
  49. 4
      tacker/tests/unit/vnfm/test_plugin.py
  50. 2
      tacker/tests/unit/vnfm/test_vim_client.py
  51. 3
      tacker/tests/unit/vnfpkgm/test_controller.py
  52. 1
      test-requirements.txt

@ -53,7 +53,6 @@ linecache2==1.0.0
Mako==1.0.7
MarkupSafe==1.0
mccabe==0.2.1
mock==3.0.0
monotonic==1.4
mox3==0.25.0
msgpack==0.5.6

@ -87,7 +87,7 @@ def validate_head_file(config):
if len(script.get_heads()) > 1:
alembic_util.err(_('Timeline branches unable to generate timeline'))
head_path = os.path.join(script.versions, HEAD_FILENAME)
head_path = os.path.join(str(script.versions), HEAD_FILENAME)
if (os.path.isfile(head_path) and
open(head_path).read().strip() == script.get_current_head()):
return
@ -100,7 +100,7 @@ def update_head_file(config):
if len(script.get_heads()) > 1:
alembic_util.err(_('Timeline branches unable to generate timeline'))
head_path = os.path.join(script.versions, HEAD_FILENAME)
head_path = os.path.join(str(script.versions), HEAD_FILENAME)
with open(head_path, 'w+') as f:
f.write(script.get_current_head())

@ -21,11 +21,11 @@ import logging
import os
import os.path
import sys
from unittest import mock
import weakref
import eventlet.timeout
import fixtures
import mock
from oslo_config import cfg
from oslo_messaging import conffixture as messaging_conffixture
import testtools

@ -13,7 +13,7 @@
# under the License.
import mock
from unittest import mock
import oslo_i18n

@ -14,7 +14,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 oslo_utils import uuidutils
from webob import exc

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

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker import manager

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

@ -13,8 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import ddt
import mock
import six
from webob import exc

@ -14,8 +14,8 @@
# under the License.
import os
from unittest import mock
import mock
from oslo_config import cfg
from oslo_policy import policy as common_policy
from oslo_utils import uuidutils

@ -13,7 +13,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 oslo_config import fixture as config_fixture
from requests_mock.contrib import fixture as requests_mock_fixture

@ -14,8 +14,8 @@
# limitations under the License.
import os
from unittest import mock
import mock
from oslo_config import cfg
from tacker.common import config

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import shutil
import testtools
from unittest import mock
from tacker.common import csar_utils
from tacker.common import exceptions

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

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker.common.rpc import BackingOffClient
from tacker.conductor.conductorrpc import vnf_pkgm_rpc

@ -14,12 +14,12 @@
# limitations under the License.
import os
from oslo_config import cfg
import shutil
import sys
from unittest import mock
from glance_store import exceptions as store_exceptions
import mock
from oslo_config import cfg
from six.moves import urllib
import six.moves.urllib.error as urlerr
import yaml

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

@ -16,8 +16,8 @@
# @author Mark McClain (DreamHost)
import sys
from unittest import mock
import mock
from tacker.db.migration import cli
from tacker.tests import base

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker.common import exceptions

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

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
import glance_store
from six.moves import urllib

@ -13,7 +13,8 @@
# under the License.
from collections import namedtuple
import mock
from unittest import mock
from oslo_config import cfg
from tacker import context as t_context

@ -14,9 +14,9 @@
# under the License.
import os
from unittest import mock
from keystoneauth1 import exceptions
import mock
from oslo_config import cfg
from tacker import context as t_context

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

@ -15,11 +15,11 @@
import codecs
from datetime import datetime
import mock
import os
from oslo_utils import uuidutils
from unittest import mock
from unittest.mock import patch
from mock import patch
from oslo_utils import uuidutils
from tacker.common import exceptions
from tacker import context

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from tacker.common import exceptions
from tacker import context

@ -13,16 +13,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker.common import exceptions
from tacker import context
from tacker.db import api as sqlalchemy_api
from tacker import objects
from tacker.tests.unit.db.base import SqlTestCase
from tacker.tests.unit.objects import fakes
from tacker.tests import uuidsentinel
from tacker.db import api as sqlalchemy_api
get_engine = sqlalchemy_api.get_engine

@ -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 oslo_utils import uuidutils
from tacker.common import exceptions

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker.common import exceptions
from tacker import context

@ -13,7 +13,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 webob import Request

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

@ -15,8 +15,9 @@
"""Test of Policy Engine For Tacker"""
from unittest import mock
import fixtures
import mock
import six
from oslo_policy import policy as common_policy

@ -14,10 +14,11 @@
# under the License.
import os
from unittest import mock
import oslo_i18n
import socket
import mock
from oslo_config import cfg
import six.moves.urllib.request as urllibrequest
import testtools

@ -14,8 +14,8 @@
# under the License.
import sys
from unittest import mock
import mock
from six import moves
from tacker.tests import base

@ -12,9 +12,9 @@
# 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
import ddt
import mock
from oslo_serialization import jsonutils
from six.moves import http_client
from webob import exc

@ -14,10 +14,11 @@
# limitations under the License.
import os
import shutil
from unittest import mock
import fixtures
import mock
from oslo_config import cfg
from tacker.common import exceptions
from tacker.common import utils
from tacker import context

@ -15,8 +15,7 @@
import codecs
import os
import mock
from unittest import mock
import yaml
from oslo_serialization import jsonutils

@ -13,13 +13,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import ddt
import importlib
import json
import mock
import os
import requests
import tempfile
from unittest import mock
import ddt
import requests
import yaml
from tacker.common import exceptions

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tacker import context
from tacker.db.common_services import common_services_db_plugin

@ -12,7 +12,8 @@
# under the License.
#
import mock
from unittest import mock
import six.moves.urllib.error as urlerr
import testtools

@ -12,8 +12,8 @@
# under the License.
#
import mock
import testtools
from unittest import mock
from tacker.vnfm.monitor_drivers.ping import ping

@ -12,9 +12,9 @@
# under the License.
#
import mock
from tacker.vnfm.monitor_drivers.zabbix import zabbix
import testtools
from unittest import mock
class TestVNFMonitorZabbix(testtools.TestCase):

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import testtools
from unittest import mock
from tacker import context
from tacker.db.common_services import common_services_db_plugin

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import testtools
from unittest import mock
from tacker import context
from tacker.db.common_services import common_services_db_plugin

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import testtools
from unittest import mock
from tacker.common import clients
from tacker import context

@ -13,8 +13,8 @@
#
from datetime import datetime
from unittest import mock
import mock
from oslo_utils import uuidutils
from tacker import context

@ -14,10 +14,10 @@
# under the License.
from datetime import datetime
import mock
from unittest import mock
from oslo_utils import uuidutils
from tacker import context
from tacker.db.common_services import common_services_db_plugin
from tacker.db.nfvo import nfvo_db

@ -12,7 +12,8 @@
# under the License.
#
import mock
from unittest import mock
from oslo_serialization import jsonutils
from oslo_utils import timeutils
import testtools

@ -14,10 +14,10 @@
# under the License.
from datetime import datetime
from unittest import mock
from unittest.mock import patch
import ddt
import mock
from mock import patch
from oslo_utils import uuidutils
import yaml

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from sqlalchemy.orm import exc as orm_exc
from unittest import mock
from tacker.extensions import nfvo
from tacker import manager

@ -12,8 +12,9 @@
# 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
import ddt
import mock
from oslo_serialization import jsonutils
from six.moves import http_client
from six.moves import urllib

@ -9,7 +9,6 @@ ddt>=1.0.1 # MIT
doc8>=0.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
hacking>=3.0.1,<3.1.0 # Apache-2.0
mock>=3.0.0 # BSD
python-subunit>=1.0.0 # Apache-2.0/BSD
python-tackerclient>=0.8.0 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0

Loading…
Cancel
Save