diff --git a/lower-constraints.txt b/lower-constraints.txt index d0b9e95b5d..5003d9c7c1 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -9,7 +9,6 @@ flake8==2.6.2 hacking==1.1.0 httplib2==0.9.1 kombu==4.0.0 -mock==2.0.0 netaddr==0.7.18 neutron-lib==2.0.0 octavia-lib==1.3.1 diff --git a/requirements.txt b/requirements.txt index 3c4c7afb11..99e9c74690 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,7 +29,6 @@ oslo.vmware>=2.17.0 # Apache-2.0 PrettyTable<0.8,>=0.7.2 # BSD tooz>=1.58.0 # Apache-2.0 decorator>=4.4.1 # BSD -mock>=2.0.0 # BSD # These repos are installed from git in OpenStack CI if the job # configures them as required-projects: diff --git a/test-requirements.txt b/test-requirements.txt index aa45eff896..e3a0eaf0bf 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,7 +7,6 @@ coverage!=4.4,>=4.0 # Apache-2.0 fixtures>=3.0.0 # Apache-2.0/BSD flake8>=2.6.0 flake8-import-order==0.12 # LGPLv3 -mock>=2.0.0 # BSD psycopg2>=2.7 # LGPL/ZPL PyMySQL>=0.7.6 # MIT License oslotest>=3.2.0 # Apache-2.0 diff --git a/vmware_nsx/plugins/common_v3/plugin.py b/vmware_nsx/plugins/common_v3/plugin.py index 14000c05b7..5a463a1633 100644 --- a/vmware_nsx/plugins/common_v3/plugin.py +++ b/vmware_nsx/plugins/common_v3/plugin.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + import decorator -import mock import netaddr from oslo_config import cfg from oslo_db import exception as db_exc diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index a5130ef5e5..595d37a7d4 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -14,8 +14,8 @@ # under the License. import copy import time +from unittest import mock -import mock import netaddr from neutron_lib.api.definitions import address_scope diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py index bb7f14bb9e..25acbda50d 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py @@ -14,7 +14,7 @@ import time -import mock +from unittest import mock from oslo_config import cfg from oslo_log import log as logging diff --git a/vmware_nsx/tests/unit/__init__.py b/vmware_nsx/tests/unit/__init__.py index 8a384c44c0..c93cc643dd 100644 --- a/vmware_nsx/tests/unit/__init__.py +++ b/vmware_nsx/tests/unit/__init__.py @@ -17,7 +17,7 @@ import os import time -import mock +from unittest import mock from vmware_nsx.api_client import client as nsx_client from vmware_nsx.api_client import eventlet_client diff --git a/vmware_nsx/tests/unit/common_plugin/test_housekeeper.py b/vmware_nsx/tests/unit/common_plugin/test_housekeeper.py index cc4da8ba82..98617c5497 100644 --- a/vmware_nsx/tests/unit/common_plugin/test_housekeeper.py +++ b/vmware_nsx/tests/unit/common_plugin/test_housekeeper.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.tests import base from neutron_lib import exceptions as n_exc diff --git a/vmware_nsx/tests/unit/dvs/test_plugin.py b/vmware_nsx/tests/unit/dvs/test_plugin.py index e861f5fbee..1f5bbaf9d5 100644 --- a/vmware_nsx/tests/unit/dvs/test_plugin.py +++ b/vmware_nsx/tests/unit/dvs/test_plugin.py @@ -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 neutron_lib import context from oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/dvs/test_utils.py b/vmware_nsx/tests/unit/dvs/test_utils.py index eda5bdb19b..fafc09b636 100644 --- a/vmware_nsx/tests/unit/dvs/test_utils.py +++ b/vmware_nsx/tests/unit/dvs/test_utils.py @@ -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_config import cfg from oslo_vmware import api diff --git a/vmware_nsx/tests/unit/extensions/test_dhcp_mtu.py b/vmware_nsx/tests/unit/extensions/test_dhcp_mtu.py index db8dc42de0..4b78d8d7bb 100644 --- a/vmware_nsx/tests/unit/extensions/test_dhcp_mtu.py +++ b/vmware_nsx/tests/unit/extensions/test_dhcp_mtu.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db from neutron_lib.db import api as db_api diff --git a/vmware_nsx/tests/unit/extensions/test_dns_search_domain.py b/vmware_nsx/tests/unit/extensions/test_dns_search_domain.py index c2ce9e0240..e7a6053bde 100644 --- a/vmware_nsx/tests/unit/extensions/test_dns_search_domain.py +++ b/vmware_nsx/tests/unit/extensions/test_dns_search_domain.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db from neutron_lib.db import api as db_api diff --git a/vmware_nsx/tests/unit/extensions/test_metadata.py b/vmware_nsx/tests/unit/extensions/test_metadata.py index 721c8b0871..c77e9458af 100644 --- a/vmware_nsx/tests/unit/extensions/test_metadata.py +++ b/vmware_nsx/tests/unit/extensions/test_metadata.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + import netaddr from neutron_lib import constants from neutron_lib import exceptions as n_exc diff --git a/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py b/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py index 9a9f10d6ff..7547abc501 100644 --- a/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py +++ b/vmware_nsx/tests/unit/extensions/test_provider_security_groups.py @@ -12,7 +12,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 import webob.exc from neutron.db import db_base_plugin_v2 diff --git a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py index 2f906eae86..e68e3db0ee 100644 --- a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py +++ b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock import webob.exc from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/extensions/test_security_group_policy.py b/vmware_nsx/tests/unit/extensions/test_security_group_policy.py index e129031823..10d377fce4 100644 --- a/vmware_nsx/tests/unit/extensions/test_security_group_policy.py +++ b/vmware_nsx/tests/unit/extensions/test_security_group_policy.py @@ -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 cfg import webob.exc diff --git a/vmware_nsx/tests/unit/extensions/test_securitygroup.py b/vmware_nsx/tests/unit/extensions/test_securitygroup.py index 059f6069d9..56e3e1fdad 100644 --- a/vmware_nsx/tests/unit/extensions/test_securitygroup.py +++ b/vmware_nsx/tests/unit/extensions/test_securitygroup.py @@ -12,7 +12,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 neutron.tests.unit.extensions import test_securitygroup as test_ext_sg diff --git a/vmware_nsx/tests/unit/nsx_p/test_dhcp_metadata.py b/vmware_nsx/tests/unit/nsx_p/test_dhcp_metadata.py index 7ae487d2c5..e102953de7 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_dhcp_metadata.py +++ b/vmware_nsx/tests/unit/nsx_p/test_dhcp_metadata.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock -import netaddr +from unittest import mock +import netaddr from oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_p/test_fwaas_v2_driver.py b/vmware_nsx/tests/unit/nsx_p/test_fwaas_v2_driver.py index adcf235016..d9752f2fa7 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_fwaas_v2_driver.py +++ b/vmware_nsx/tests/unit/nsx_p/test_fwaas_v2_driver.py @@ -15,7 +15,7 @@ import copy -import mock +from unittest import mock from neutron_lib.api.definitions import constants as fwaas_consts from neutron_lib.plugins import directory diff --git a/vmware_nsx/tests/unit/nsx_p/test_plugin.py b/vmware_nsx/tests/unit/nsx_p/test_plugin.py index 27f3a9a896..591b5f6a6e 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_p/test_plugin.py @@ -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 oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_p/test_policy_dhcp_metadata.py b/vmware_nsx/tests/unit/nsx_p/test_policy_dhcp_metadata.py index b48eb2bf1d..c43c34d358 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_policy_dhcp_metadata.py +++ b/vmware_nsx/tests/unit/nsx_p/test_policy_dhcp_metadata.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock -import netaddr +from unittest import mock +import netaddr from oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_tvd/test_plugin.py b/vmware_nsx/tests/unit/nsx_tvd/test_plugin.py index 5984f4e4e1..2dcb2cb9c3 100644 --- a/vmware_nsx/tests/unit/nsx_tvd/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_tvd/test_plugin.py @@ -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 oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_backup_edge.py b/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_backup_edge.py index 5691002fa0..585a80ccaf 100644 --- a/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_backup_edge.py +++ b/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_backup_edge.py @@ -12,8 +12,8 @@ # 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 mock from neutron.tests import base from neutron_lib.plugins import constants diff --git a/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_dhcp_edge.py b/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_dhcp_edge.py index 525f704c98..f43396bdb9 100644 --- a/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_dhcp_edge.py +++ b/vmware_nsx/tests/unit/nsx_v/housekeeper/test_error_dhcp_edge.py @@ -15,8 +15,8 @@ import copy import datetime +from unittest import mock -import mock from neutron.tests import base from neutron_lib.plugins import constants diff --git a/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py b/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py index 22ea35acd8..16326be08f 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py +++ b/vmware_nsx/tests/unit/nsx_v/test_edge_loadbalancer_driver_v2.py @@ -13,13 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. +from unittest import mock + +from oslo_config import cfg -import mock from neutron.services.flavors import flavors_plugin from neutron.tests import base from neutron_lib import context from neutron_lib import exceptions as n_exc -from oslo_config import cfg from vmware_nsx.db import nsxv_db from vmware_nsx.services.lbaas import base_mgr diff --git a/vmware_nsx/tests/unit/nsx_v/test_fwaas_v2_driver.py b/vmware_nsx/tests/unit/nsx_v/test_fwaas_v2_driver.py index 75bda89651..b89fd1fc56 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_fwaas_v2_driver.py +++ b/vmware_nsx/tests/unit/nsx_v/test_fwaas_v2_driver.py @@ -15,7 +15,7 @@ import copy -import mock +from unittest import mock from neutron_lib.plugins import directory diff --git a/vmware_nsx/tests/unit/nsx_v/test_lbaas_common.py b/vmware_nsx/tests/unit/nsx_v/test_lbaas_common.py index 1a45a82fbf..c4b6db1fa6 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_lbaas_common.py +++ b/vmware_nsx/tests/unit/nsx_v/test_lbaas_common.py @@ -12,8 +12,8 @@ # 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 mock from neutron.tests import base from vmware_nsx.plugins.nsx_v.vshield import vcns_driver diff --git a/vmware_nsx/tests/unit/nsx_v/test_nsxv_loadbalancer.py b/vmware_nsx/tests/unit/nsx_v/test_nsxv_loadbalancer.py index 788e889802..96da8807c1 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_nsxv_loadbalancer.py +++ b/vmware_nsx/tests/unit/nsx_v/test_nsxv_loadbalancer.py @@ -12,11 +12,11 @@ # 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 oslo_serialization import jsonutils +from unittest import mock from neutron.tests import base +from oslo_serialization import jsonutils + from vmware_nsx.plugins.nsx_v.vshield import nsxv_loadbalancer from vmware_nsx.plugins.nsx_v.vshield import vcns diff --git a/vmware_nsx/tests/unit/nsx_v/test_plugin.py b/vmware_nsx/tests/unit/nsx_v/test_plugin.py index 2c555e5aeb..e0ca78572e 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v/test_plugin.py @@ -16,11 +16,11 @@ import contextlib import copy import re +from unittest import mock import decorator from eventlet import greenthread -import mock import netaddr from neutron.db import securitygroups_db as sg_db from neutron.extensions import address_scope diff --git a/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py b/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py index a44315b15f..69fce0a674 100644 --- a/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py +++ b/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py @@ -12,16 +12,16 @@ # License for the specific language governing permissions and limitations # under the License. # +from unittest import mock -import mock +from neutron.tests.unit import testlib_api from neutron_lib import constants from neutron_lib import context +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_utils import uuidutils from six import moves -from neutron.tests.unit import testlib_api -from neutron_lib import exceptions as n_exc from vmware_nsx.common import config as conf from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import nsxv_constants diff --git a/vmware_nsx/tests/unit/nsx_v/vshield/test_vcns_driver.py b/vmware_nsx/tests/unit/nsx_v/vshield/test_vcns_driver.py index 318f1afba0..fc54542296 100644 --- a/vmware_nsx/tests/unit/nsx_v/vshield/test_vcns_driver.py +++ b/vmware_nsx/tests/unit/nsx_v/vshield/test_vcns_driver.py @@ -12,9 +12,9 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock from eventlet import greenthread -import mock from neutron.tests import base from neutron_lib import context as neutron_context diff --git a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_mismatch_logical_port.py b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_mismatch_logical_port.py index 031fb80399..61d7a84d47 100644 --- a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_mismatch_logical_port.py +++ b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_mismatch_logical_port.py @@ -12,8 +12,8 @@ # 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 mock from neutron.tests import base from neutron_lib.plugins import constants from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_dhcp_server.py b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_dhcp_server.py index 4a7e6f6957..26d1775e11 100644 --- a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_dhcp_server.py +++ b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_dhcp_server.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.tests import base from neutron_lib.plugins import constants from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_firewall_section.py b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_firewall_section.py index a74b7108c7..ae0f332a05 100644 --- a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_firewall_section.py +++ b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_firewall_section.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.tests import base from neutron_lib.plugins import constants from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_router.py b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_router.py index e847979394..a386e7def6 100644 --- a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_router.py +++ b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_router.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.tests import base from neutron_lib.plugins import constants from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_switch.py b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_switch.py index bb6f1e7c87..ff11240a5c 100644 --- a/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_switch.py +++ b/vmware_nsx/tests/unit/nsx_v3/housekeeper/test_orphaned_logical_switch.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -import mock +from unittest import mock + from neutron.tests import base from neutron_lib.plugins import constants from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/test_client_cert.py b/vmware_nsx/tests/unit/nsx_v3/test_client_cert.py index 40a8128b41..6088128bf2 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_client_cert.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_client_cert.py @@ -14,8 +14,8 @@ # limitations under the License. import os +from unittest import mock -import mock from oslo_config import cfg from neutron.tests.unit import testlib_api diff --git a/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py b/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py index 9f5c9f1613..6f97ba131e 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_dhcp_metadata.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock -import netaddr +from unittest import mock +import netaddr from oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/nsx_v3/test_fwaas_v2_driver.py b/vmware_nsx/tests/unit/nsx_v3/test_fwaas_v2_driver.py index e76010459c..84355c0b3d 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_fwaas_v2_driver.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_fwaas_v2_driver.py @@ -14,8 +14,7 @@ # under the License. import copy - -import mock +from unittest import mock from neutron_lib.plugins import directory diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index af5e587309..f5fe9a5085 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -12,8 +12,8 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock -import mock import netaddr from neutron.db import l3_db from neutron.db import models_v2 diff --git a/vmware_nsx/tests/unit/nsxlib/mh/base.py b/vmware_nsx/tests/unit/nsxlib/mh/base.py index fb08001f4e..e67801204a 100644 --- a/vmware_nsx/tests/unit/nsxlib/mh/base.py +++ b/vmware_nsx/tests/unit/nsxlib/mh/base.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from unittest import mock -import mock from neutron.tests import base from neutron.tests.unit.api.v2 import test_base diff --git a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py index 62308ba36d..df89680bb5 100644 --- a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py +++ b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py @@ -12,12 +12,13 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +from unittest import mock + +import six -import mock from neutron.tests import base from neutron_lib import exceptions from oslo_serialization import jsonutils -import six from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc diff --git a/vmware_nsx/tests/unit/nsxlib/mh/test_switch.py b/vmware_nsx/tests/unit/nsxlib/mh/test_switch.py index 584f36eaa8..fcf61deb56 100644 --- a/vmware_nsx/tests/unit/nsxlib/mh/test_switch.py +++ b/vmware_nsx/tests/unit/nsxlib/mh/test_switch.py @@ -15,8 +15,8 @@ # import hashlib +from unittest import mock -import mock from neutron.tests.unit.api.v2 import test_base from neutron_lib import constants from neutron_lib import exceptions diff --git a/vmware_nsx/tests/unit/osc/v2/test_port.py b/vmware_nsx/tests/unit/osc/v2/test_port.py index 0a835678f3..ba8073b9ce 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_port.py +++ b/vmware_nsx/tests/unit/osc/v2/test_port.py @@ -14,8 +14,8 @@ # under the License. import re +from unittest import mock -import mock from openstackclient.tests.unit.network.v2 import fakes as network_fakes from openstackclient.tests.unit.network.v2 import test_port from openstackclient.tests.unit import utils as tests_utils diff --git a/vmware_nsx/tests/unit/osc/v2/test_router.py b/vmware_nsx/tests/unit/osc/v2/test_router.py index 7974230fa9..d9c640f3b2 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_router.py +++ b/vmware_nsx/tests/unit/osc/v2/test_router.py @@ -14,8 +14,8 @@ # under the License. import re +from unittest import mock -import mock from openstackclient.tests.unit.network.v2 import test_router from openstackclient.tests.unit import utils as tests_utils diff --git a/vmware_nsx/tests/unit/osc/v2/test_security_group.py b/vmware_nsx/tests/unit/osc/v2/test_security_group.py index e07c56b02a..dade842949 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_security_group.py +++ b/vmware_nsx/tests/unit/osc/v2/test_security_group.py @@ -14,13 +14,12 @@ # under the License. import re +from unittest import mock -import mock from openstackclient.tests.unit.network.v2 import ( test_security_group_network as test_security_group) from openstackclient.tests.unit import utils as tests_utils - from vmware_nsx.extensions import providersecuritygroup from vmware_nsx.extensions import securitygrouplogging from vmware_nsx.extensions import securitygrouppolicy diff --git a/vmware_nsx/tests/unit/osc/v2/test_subnet.py b/vmware_nsx/tests/unit/osc/v2/test_subnet.py index f49b18df4e..4614c9bb5a 100644 --- a/vmware_nsx/tests/unit/osc/v2/test_subnet.py +++ b/vmware_nsx/tests/unit/osc/v2/test_subnet.py @@ -14,8 +14,8 @@ # under the License. import re +from unittest import mock -import mock from openstackclient.tests.unit.network.v2 import test_subnet from openstackclient.tests.unit import utils as tests_utils diff --git a/vmware_nsx/tests/unit/services/dynamic_routing/test_nsxv_bgp_driver.py b/vmware_nsx/tests/unit/services/dynamic_routing/test_nsxv_bgp_driver.py index 4fc0831651..ec9ec2d3c4 100644 --- a/vmware_nsx/tests/unit/services/dynamic_routing/test_nsxv_bgp_driver.py +++ b/vmware_nsx/tests/unit/services/dynamic_routing/test_nsxv_bgp_driver.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. import contextlib +from unittest import mock -import mock from neutron.api import extensions from neutron_dynamic_routing.db import bgp_db # noqa from neutron_dynamic_routing import extensions as dr_extensions diff --git a/vmware_nsx/tests/unit/services/flowclassifier/test_nsxv_driver.py b/vmware_nsx/tests/unit/services/flowclassifier/test_nsxv_driver.py index 0ce5d22b1e..f0e099c3eb 100644 --- a/vmware_nsx/tests/unit/services/flowclassifier/test_nsxv_driver.py +++ b/vmware_nsx/tests/unit/services/flowclassifier/test_nsxv_driver.py @@ -12,14 +12,11 @@ # 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 oslo_config import cfg from oslo_utils import importutils -from vmware_nsx.services.flowclassifier.nsx_v import driver as nsx_v_driver -from vmware_nsx.tests import unit as vmware -from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns - from neutron.api import extensions as api_ext from neutron.common import config from neutron_lib.api.definitions import portbindings @@ -33,6 +30,10 @@ from networking_sfc.services.flowclassifier.common import exceptions as fc_exc from networking_sfc.tests import base from networking_sfc.tests.unit.db import test_flowclassifier_db +from vmware_nsx.services.flowclassifier.nsx_v import driver as nsx_v_driver +from vmware_nsx.tests import unit as vmware +from vmware_nsx.tests.unit.nsx_v.vshield import fake_vcns + class TestNsxvFlowClassifierDriver( test_flowclassifier_db.FlowClassifierDbPluginTestCaseBase, diff --git a/vmware_nsx/tests/unit/services/ipam/test_nsxv3_driver.py b/vmware_nsx/tests/unit/services/ipam/test_nsxv3_driver.py index c9c21d74af..e8c3e14e45 100644 --- a/vmware_nsx/tests/unit/services/ipam/test_nsxv3_driver.py +++ b/vmware_nsx/tests/unit/services/ipam/test_nsxv3_driver.py @@ -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. -import mock -import netaddr +from unittest import mock + +import netaddr from oslo_config import cfg from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/services/l2gateway/test_nsxv3_driver.py b/vmware_nsx/tests/unit/services/l2gateway/test_nsxv3_driver.py index a9c6c2eb22..19595f6328 100644 --- a/vmware_nsx/tests/unit/services/l2gateway/test_nsxv3_driver.py +++ b/vmware_nsx/tests/unit/services/l2gateway/test_nsxv3_driver.py @@ -12,7 +12,8 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -import mock + +from unittest import mock from networking_l2gw.db.l2gateway import l2gateway_db from networking_l2gw.services.l2gateway.common import config diff --git a/vmware_nsx/tests/unit/services/l2gateway/test_nsxv_driver.py b/vmware_nsx/tests/unit/services/l2gateway/test_nsxv_driver.py index ac70d502be..947485c135 100644 --- a/vmware_nsx/tests/unit/services/l2gateway/test_nsxv_driver.py +++ b/vmware_nsx/tests/unit/services/l2gateway/test_nsxv_driver.py @@ -12,13 +12,14 @@ # 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 neutron.tests import base +from unittest import mock from networking_l2gw.db.l2gateway import l2gateway_db +from neutron.tests import base from neutron_lib import context from neutron_lib import exceptions as n_exc + from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.db import nsxv_db from vmware_nsx.dvs import dvs_utils diff --git a/vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py b/vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py index a67cdc159f..bfbf4ab870 100644 --- a/vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py +++ b/vmware_nsx/tests/unit/services/lbaas/test_nsxp_driver.py @@ -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 neutron.tests import base from neutron_lib import context from neutron_lib import exceptions as n_exc diff --git a/vmware_nsx/tests/unit/services/lbaas/test_nsxv3_driver.py b/vmware_nsx/tests/unit/services/lbaas/test_nsxv3_driver.py index 86d4c36a75..79aa56737b 100644 --- a/vmware_nsx/tests/unit/services/lbaas/test_nsxv3_driver.py +++ b/vmware_nsx/tests/unit/services/lbaas/test_nsxv3_driver.py @@ -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 neutron.tests import base from neutron_lib import context from neutron_lib import exceptions as n_exc diff --git a/vmware_nsx/tests/unit/services/lbaas/test_octavia_driver.py b/vmware_nsx/tests/unit/services/lbaas/test_octavia_driver.py index d0f5fe2a84..a5a55f4a1e 100644 --- a/vmware_nsx/tests/unit/services/lbaas/test_octavia_driver.py +++ b/vmware_nsx/tests/unit/services/lbaas/test_octavia_driver.py @@ -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 decorator -import mock import testtools from oslo_utils import uuidutils diff --git a/vmware_nsx/tests/unit/services/lbaas/test_octavia_listener.py b/vmware_nsx/tests/unit/services/lbaas/test_octavia_listener.py index 608f5abc34..7140e71fab 100644 --- a/vmware_nsx/tests/unit/services/lbaas/test_octavia_listener.py +++ b/vmware_nsx/tests/unit/services/lbaas/test_octavia_listener.py @@ -12,8 +12,8 @@ # 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 mock import testtools from neutron_lib import exceptions diff --git a/vmware_nsx/tests/unit/services/qos/test_nsxp_notification.py b/vmware_nsx/tests/unit/services/qos/test_nsxp_notification.py index a6512ee61b..9ee95c0c8e 100644 --- a/vmware_nsx/tests/unit/services/qos/test_nsxp_notification.py +++ b/vmware_nsx/tests/unit/services/qos/test_nsxp_notification.py @@ -12,7 +12,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 neutron_lib import context from neutron_lib import exceptions diff --git a/vmware_nsx/tests/unit/services/qos/test_nsxv3_notification.py b/vmware_nsx/tests/unit/services/qos/test_nsxv3_notification.py index e3180a1b5b..d6b2c15d0e 100644 --- a/vmware_nsx/tests/unit/services/qos/test_nsxv3_notification.py +++ b/vmware_nsx/tests/unit/services/qos/test_nsxv3_notification.py @@ -12,7 +12,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 neutron_lib import context from neutron_lib import exceptions diff --git a/vmware_nsx/tests/unit/services/qos/test_nsxv_notification.py b/vmware_nsx/tests/unit/services/qos/test_nsxv_notification.py index 6c1c56e533..baa6363cba 100644 --- a/vmware_nsx/tests/unit/services/qos/test_nsxv_notification.py +++ b/vmware_nsx/tests/unit/services/qos/test_nsxv_notification.py @@ -13,8 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. import copy +from unittest import mock -import mock from neutron.services.qos import qos_plugin from neutron.tests.unit.services.qos import base from neutron_lib import context @@ -200,11 +200,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase, # make sure the dvs was updated self.assertTrue(dvs_update_mock.called) - @mock.patch.object(qos_com_utils, 'update_network_policy_binding') - @mock.patch.object(dvs.DvsManager, 'update_port_groups_config') - def _test_rule_action_notification(self, action, - dvs_update_mock, - update_bindings_mock): + def _test_rule_action_notification(self, action): # Create a policy with a rule _policy = QosPolicy( self.ctxt, **self.policy_data['policy']) @@ -212,9 +208,13 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase, # set the rule in the policy data setattr(_policy, "rules", [self.rule]) - with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.' - 'get_policy', - return_value=_policy) as get_rules_mock,\ + with mock.patch.object(qos_com_utils, + 'update_network_policy_binding'),\ + mock.patch.object(dvs.DvsManager, 'update_port_groups_config' + ) as dvs_update_mock,\ + mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.' + 'get_policy', + return_value=_policy) as get_rules_mock,\ mock.patch.object(QosPolicy, 'get_object', return_value=_policy): # create the network to use this policy net = self._create_net() @@ -265,11 +265,7 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase, """ self._test_rule_action_notification('delete') - @mock.patch.object(qos_com_utils, 'update_network_policy_binding') - @mock.patch.object(dvs.DvsManager, 'update_port_groups_config') - def _test_dscp_rule_action_notification(self, action, - dvs_update_mock, - update_bindings_mock): + def _test_dscp_rule_action_notification(self, action): # Create a policy with a rule _policy = QosPolicy( self.ctxt, **self.policy_data['policy']) @@ -277,9 +273,13 @@ class TestQosNsxVNotification(test_plugin.NsxVPluginV2TestCase, # set the rule in the policy data setattr(_policy, "rules", [self.dscp_rule]) plugin = self.qos_plugin - with mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.' - 'get_policy', - return_value=_policy) as rules_mock,\ + with mock.patch.object(qos_com_utils, + 'update_network_policy_binding'),\ + mock.patch.object(dvs.DvsManager, 'update_port_groups_config' + ) as dvs_update_mock,\ + mock.patch('neutron.services.qos.qos_plugin.QoSPlugin.' + 'get_policy', + return_value=_policy) as rules_mock,\ mock.patch.object(QosPolicy, 'get_object', return_value=_policy),\ mock.patch.object(self.ctxt.session, 'expunge'): diff --git a/vmware_nsx/tests/unit/services/trunk/test_nsxp_driver.py b/vmware_nsx/tests/unit/services/trunk/test_nsxp_driver.py index 41ede553fc..e9e242d916 100644 --- a/vmware_nsx/tests/unit/services/trunk/test_nsxp_driver.py +++ b/vmware_nsx/tests/unit/services/trunk/test_nsxp_driver.py @@ -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 neutron.tests import base diff --git a/vmware_nsx/tests/unit/services/trunk/test_nsxv3_driver.py b/vmware_nsx/tests/unit/services/trunk/test_nsxv3_driver.py index a203e2f1b6..2856ecc511 100644 --- a/vmware_nsx/tests/unit/services/trunk/test_nsxv3_driver.py +++ b/vmware_nsx/tests/unit/services/trunk/test_nsxv3_driver.py @@ -13,10 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import mock +from unittest import mock from neutron.tests import base - from neutron_lib import context from oslo_config import cfg from oslo_utils import importutils diff --git a/vmware_nsx/tests/unit/services/vpnaas/test_nsxp_vpnaas.py b/vmware_nsx/tests/unit/services/vpnaas/test_nsxp_vpnaas.py index 8f14752e68..74453f0054 100644 --- a/vmware_nsx/tests/unit/services/vpnaas/test_nsxp_vpnaas.py +++ b/vmware_nsx/tests/unit/services/vpnaas/test_nsxp_vpnaas.py @@ -16,8 +16,7 @@ from collections import namedtuple import contextlib -import mock -from oslo_utils import uuidutils +from unittest import mock from neutron.db import l3_db from neutron.db.models import l3 as l3_models @@ -26,6 +25,7 @@ from neutron_lib import context as n_ctx from neutron_lib.plugins import directory from neutron_vpnaas.db.vpn import vpn_models # noqa from neutron_vpnaas.tests import base +from oslo_utils import uuidutils from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.services.vpnaas.nsxp import ipsec_driver diff --git a/vmware_nsx/tests/unit/services/vpnaas/test_nsxv3_vpnaas.py b/vmware_nsx/tests/unit/services/vpnaas/test_nsxv3_vpnaas.py index b7b61de8a7..49610be16d 100644 --- a/vmware_nsx/tests/unit/services/vpnaas/test_nsxv3_vpnaas.py +++ b/vmware_nsx/tests/unit/services/vpnaas/test_nsxv3_vpnaas.py @@ -15,9 +15,7 @@ from collections import namedtuple import contextlib - -import mock -from oslo_utils import uuidutils +from unittest import mock from neutron.db import l3_db from neutron.db.models import l3 as l3_models @@ -26,6 +24,7 @@ from neutron_lib import context as n_ctx from neutron_lib.plugins import directory from neutron_vpnaas.db.vpn import vpn_models # noqa from neutron_vpnaas.tests import base +from oslo_utils import uuidutils from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.services.vpnaas.nsxv3 import ipsec_driver @@ -726,5 +725,3 @@ class TestVpnaasDriver(test_plugin.NsxV3PluginTestCaseMixin): self.driver.delete_vpnservice( self.context, FAKE_VPNSERVICE) delete_service.assert_called_once() - - pass diff --git a/vmware_nsx/tests/unit/services/vpnaas/test_nsxv_vpnaas.py b/vmware_nsx/tests/unit/services/vpnaas/test_nsxv_vpnaas.py index 12ce92059e..4d21ae8945 100644 --- a/vmware_nsx/tests/unit/services/vpnaas/test_nsxv_vpnaas.py +++ b/vmware_nsx/tests/unit/services/vpnaas/test_nsxv_vpnaas.py @@ -15,7 +15,7 @@ import contextlib -import mock +from unittest import mock from neutron_lib.api.definitions import external_net as extnet_apidef from neutron_lib import context diff --git a/vmware_nsx/tests/unit/shell/test_admin_utils.py b/vmware_nsx/tests/unit/shell/test_admin_utils.py index b26fce03b8..2e89528184 100644 --- a/vmware_nsx/tests/unit/shell/test_admin_utils.py +++ b/vmware_nsx/tests/unit/shell/test_admin_utils.py @@ -15,7 +15,8 @@ import abc -import mock +from unittest import mock + from oslo_config import cfg from oslo_log import _options from oslo_log import log as logging @@ -296,7 +297,7 @@ class TestNsxvAdminUtils(AbstractTestAdminUtils, except SystemExit: return else: - self.assertTrue(False) + self.fail() class TestNsxv3AdminUtils(AbstractTestAdminUtils,