Browse Source

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)
changes/81/707581/1
asarfaty Adit Sarfaty 3 weeks ago
parent
commit
38a5f8c11c
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      vmware_nsx/tests/unit/shell/test_admin_utils.py

+ 11
- 0
vmware_nsx/tests/unit/shell/test_admin_utils.py View File

@@ -24,6 +24,7 @@ import six

from neutron.common import config as neutron_config
from neutron.db import servicetype_db # noqa
from neutron import quota
from neutron.quota import resource_registry
from neutron.tests import base
from neutron_lib.callbacks import registry
@@ -75,6 +76,12 @@ class AbstractTestAdminUtils(base.BaseTestCase):
"vmware_nsx.shell.admin.plugins.common.utils.query_yes_no")
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
def _get_plugin_name(self):
pass
@@ -158,6 +165,7 @@ class TestNsxvAdminUtils(AbstractTestAdminUtils,

mock.patch("neutron_lib.plugins.directory.get_plugin",
side_effect=get_plugin_mock).start()
self._init_mock_quota()

# Create a router to make sure we have deployed an edge
self.router = self._create_router()
@@ -311,6 +319,8 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils,
self.mock_nm_get_plugin = mock_nm_get_plugin.start()
self.mock_nm_get_plugin.return_value = self._plugin

self._init_mock_quota()

def _get_plugin_name(self):
return 'nsxv3'

@@ -357,6 +367,7 @@ class TestNsxpAdminUtils(AbstractTestAdminUtils,

def _init_mock_plugin(self):
self._plugin = nsxp_utils.NsxPolicyPluginWrapper()
self._init_mock_quota()

def test_nsxp_resources(self):
self._test_resources(resources.nsxp_resources)


Loading…
Cancel
Save