Merge "Mocking superfluous imports"
This commit is contained in:
commit
5a860f56bb
|
@ -12,3 +12,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
import sys
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
sys.modules['uuidutils'] = mock.MagicMock()
|
||||
sys.modules['xml.etree'] = mock.MagicMock()
|
||||
|
|
|
@ -18,16 +18,16 @@ test_ceph_pools_pg_protection
|
|||
|
||||
Tests for `ceph_pools_pg_protection` module.
|
||||
"""
|
||||
|
||||
import library.ceph_pools_pg_protection as validation
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
import library.ceph_pools_pg_protection as validation
|
||||
|
||||
|
||||
class TestCephPoolsPgProtection(base.TestCase):
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@ try:
|
|||
except ImportError:
|
||||
import mock
|
||||
|
||||
import library.check_ironic_boot_config as validation
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
|
||||
import library.check_ironic_boot_config as validation
|
||||
|
||||
UUIDs = [
|
||||
'13c319a4-7704-4b44-bb2e-501951879f96',
|
||||
|
|
|
@ -19,8 +19,15 @@ test_ip_range
|
|||
Tests for `ip_range` module.
|
||||
"""
|
||||
|
||||
import library.ip_range as validation
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
import library.ip_range as validation
|
||||
|
||||
|
||||
class TestIPRange(base.TestCase):
|
||||
|
|
|
@ -13,9 +13,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
import library.network_environment as validation
|
||||
from tripleo_validations.tests import base
|
||||
|
||||
|
||||
class TestNicConfigs(base.TestCase):
|
||||
|
|
|
@ -12,7 +12,13 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
from library.node_disks import _get_smallest_disk
|
||||
from library.node_disks import _has_root_device_hints
|
||||
|
|
|
@ -14,26 +14,26 @@
|
|||
# under the License.
|
||||
|
||||
try:
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import patch
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
from mock import MagicMock
|
||||
from mock import patch
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
import library.ovs_dpdk_pmd_cpus_check as validation
|
||||
from tripleo_validations.tests import base
|
||||
|
||||
|
||||
class TestOvsDpdkPmdCpusCheck(base.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOvsDpdkPmdCpusCheck, self).setUp()
|
||||
self.module = MagicMock()
|
||||
self.module = mock.MagicMock()
|
||||
|
||||
@patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_nodes_cores_info')
|
||||
@patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_cpus_list_from_mask_value')
|
||||
@mock.patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_nodes_cores_info')
|
||||
@mock.patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_cpus_list_from_mask_value')
|
||||
def test_validate_valid_pmd_cpus(self, mock_pmd_cpus, mock_cpus):
|
||||
mock_pmd_cpus.return_value = '0,1'
|
||||
mock_cpus.return_value = (
|
||||
|
@ -49,10 +49,10 @@ class TestOvsDpdkPmdCpusCheck(base.TestCase):
|
|||
self.module.exit_json.assert_called_with(
|
||||
msg="PMD CPU's configured correctly.")
|
||||
|
||||
@patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_nodes_cores_info')
|
||||
@patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_cpus_list_from_mask_value')
|
||||
@mock.patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_nodes_cores_info')
|
||||
@mock.patch('library.ovs_dpdk_pmd_cpus_check.'
|
||||
'get_cpus_list_from_mask_value')
|
||||
def test_validate_invalid_pmd_cpus(self, mock_pmd_cpus, mock_cpus):
|
||||
mock_pmd_cpus.return_value = '0,2'
|
||||
mock_cpus.return_value = (
|
||||
|
|
|
@ -13,9 +13,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
import library.switch_vlans as validation
|
||||
from tripleo_validations.tests import base
|
||||
|
||||
|
||||
class TestSwitchVlans(base.TestCase):
|
||||
|
|
|
@ -14,7 +14,14 @@
|
|||
|
||||
import collections
|
||||
|
||||
try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock
|
||||
|
||||
from tripleo_validations.tests import base
|
||||
from tripleo_validations.tests import fakes
|
||||
|
||||
from tripleo_validations import utils
|
||||
|
||||
PATH = [
|
||||
|
|
Loading…
Reference in New Issue