Fix broken unit tests
Commit I0a9b91b09d6260ff96fdba2f0a455de53bbc1f00 broke the unit tests
This patch adds the security rules quota mock were needed.
Change-Id: I7e68c9d0e40e03c0e3e708e04c996fdceed56df4
(cherry picked from commit 8fa0e7daac
)
This commit is contained in:
parent
f9ed36ec04
commit
136a4005ae
|
@ -27,6 +27,7 @@ from oslo_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit.api.v2 import test_base
|
from neutron.tests.unit.api.v2 import test_base
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
|
@ -302,10 +303,16 @@ class SyncTestCase(testlib_api.SqlTestCase):
|
||||||
"neutron_lib.plugins.directory.get_plugin")
|
"neutron_lib.plugins.directory.get_plugin")
|
||||||
self.mock_nm_get_plugin = mock_nm_get_plugin.start()
|
self.mock_nm_get_plugin = mock_nm_get_plugin.start()
|
||||||
self.mock_nm_get_plugin.return_value = self._plugin
|
self.mock_nm_get_plugin.return_value = self._plugin
|
||||||
|
self._init_mock_quota()
|
||||||
super(SyncTestCase, self).setUp()
|
super(SyncTestCase, self).setUp()
|
||||||
self.addCleanup(self.fc.reset_all)
|
self.addCleanup(self.fc.reset_all)
|
||||||
|
|
||||||
|
def _init_mock_quota(self):
|
||||||
|
make_res = mock.patch.object(quota.QuotaEngine, 'make_reservation')
|
||||||
|
self.mock_quota_make_res = make_res.start()
|
||||||
|
commit_res = mock.patch.object(quota.QuotaEngine, 'commit_reservation')
|
||||||
|
self.mock_quota_commit_res = commit_res.start()
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _populate_data(self, ctx, net_size=2, port_size=2, router_size=2):
|
def _populate_data(self, ctx, net_size=2, port_size=2, router_size=2):
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import six
|
||||||
|
|
||||||
from neutron.common import config as neutron_config
|
from neutron.common import config as neutron_config
|
||||||
from neutron.db import servicetype_db # noqa
|
from neutron.db import servicetype_db # noqa
|
||||||
|
from neutron import quota
|
||||||
from neutron.quota import resource_registry
|
from neutron.quota import resource_registry
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
|
@ -33,6 +34,7 @@ from vmware_nsx._i18n import _
|
||||||
from vmware_nsx.common import config # noqa
|
from vmware_nsx.common import config # noqa
|
||||||
from vmware_nsx.db import nsxv_db
|
from vmware_nsx.db import nsxv_db
|
||||||
from vmware_nsx.dvs import dvs_utils
|
from vmware_nsx.dvs import dvs_utils
|
||||||
|
from vmware_nsx.shell.admin.plugins.nsxp.resources import utils as nsxp_utils
|
||||||
from vmware_nsx.shell.admin.plugins.nsxv.resources import utils as nsxv_utils
|
from vmware_nsx.shell.admin.plugins.nsxv.resources import utils as nsxv_utils
|
||||||
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils as nsxv3_utils
|
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils as nsxv3_utils
|
||||||
from vmware_nsx.shell import resources
|
from vmware_nsx.shell import resources
|
||||||
|
@ -72,6 +74,12 @@ class AbstractTestAdminUtils(base.BaseTestCase):
|
||||||
"vmware_nsx.shell.admin.plugins.common.utils.query_yes_no")
|
"vmware_nsx.shell.admin.plugins.common.utils.query_yes_no")
|
||||||
mock_query.start()
|
mock_query.start()
|
||||||
|
|
||||||
|
def _init_mock_quota(self):
|
||||||
|
make_res = mock.patch.object(quota.QuotaEngine, 'make_reservation')
|
||||||
|
self.mock_quota_make_res = make_res.start()
|
||||||
|
commit_res = mock.patch.object(quota.QuotaEngine, 'commit_reservation')
|
||||||
|
self.mock_quota_commit_res = commit_res.start()
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _get_plugin_name(self):
|
def _get_plugin_name(self):
|
||||||
pass
|
pass
|
||||||
|
@ -148,6 +156,7 @@ class TestNsxvAdminUtils(AbstractTestAdminUtils,
|
||||||
|
|
||||||
mock.patch("neutron_lib.plugins.directory.get_plugin",
|
mock.patch("neutron_lib.plugins.directory.get_plugin",
|
||||||
side_effect=get_plugin_mock).start()
|
side_effect=get_plugin_mock).start()
|
||||||
|
self._init_mock_quota()
|
||||||
|
|
||||||
# Create a router to make sure we have deployed an edge
|
# Create a router to make sure we have deployed an edge
|
||||||
self.router = self.create_router()
|
self.router = self.create_router()
|
||||||
|
@ -267,6 +276,8 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils,
|
||||||
self.mock_nm_get_plugin = mock_nm_get_plugin.start()
|
self.mock_nm_get_plugin = mock_nm_get_plugin.start()
|
||||||
self.mock_nm_get_plugin.return_value = self._plugin
|
self.mock_nm_get_plugin.return_value = self._plugin
|
||||||
|
|
||||||
|
self._init_mock_quota()
|
||||||
|
|
||||||
def _get_plugin_name(self):
|
def _get_plugin_name(self):
|
||||||
return 'nsxv3'
|
return 'nsxv3'
|
||||||
|
|
||||||
|
@ -320,5 +331,9 @@ class TestNsxpAdminUtils(AbstractTestAdminUtils,
|
||||||
def _get_plugin_name(self):
|
def _get_plugin_name(self):
|
||||||
return 'nsxp'
|
return 'nsxp'
|
||||||
|
|
||||||
|
def _init_mock_plugin(self):
|
||||||
|
self._plugin = nsxp_utils.NsxPolicyPluginWrapper()
|
||||||
|
self._init_mock_quota()
|
||||||
|
|
||||||
def test_nsxp_resources(self):
|
def test_nsxp_resources(self):
|
||||||
self._test_resources(resources.nsxp_resources)
|
self._test_resources(resources.nsxp_resources)
|
||||||
|
|
Loading…
Reference in New Issue