mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Refactor common network shared and platform utils code into package (#33452)
* Refactor common network shared and platform specific code into package (part-1) As per proposal #76 refactor common network shared and platform specific code into sub-package. https://github.com/ansible/proposals/issues/76 * ansible.module_utils.network.common - command shared functions * ansible.module_utils.network.{{ platform }} - where platform is platform specific shared functions * Fix review comments * Fix review comments
This commit is contained in:
@@ -41,16 +41,16 @@ class TestJunosCommandModule(TestJunosModule):
|
||||
def setUp(self):
|
||||
super(TestJunosCommandModule, self).setUp()
|
||||
|
||||
self.mock_conn = patch('ansible.module_utils.junos.Connection')
|
||||
self.mock_conn = patch('ansible.module_utils.network.junos.junos.Connection')
|
||||
self.conn = self.mock_conn.start()
|
||||
|
||||
self.mock_netconf = patch('ansible.module_utils.junos.NetconfConnection')
|
||||
self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection')
|
||||
self.netconf_conn = self.mock_netconf.start()
|
||||
|
||||
self.mock_exec_rpc = patch('ansible.modules.network.junos.junos_command.exec_rpc')
|
||||
self.exec_rpc = self.mock_exec_rpc.start()
|
||||
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.netconf.NetconfConnection')
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection')
|
||||
self.netconf_rpc = self.mock_netconf_rpc.start()
|
||||
|
||||
self.mock_get_connection = patch('ansible.modules.network.junos.junos_command.get_connection')
|
||||
|
||||
@@ -42,10 +42,10 @@ class TestJunosConfigModule(TestJunosModule):
|
||||
self.mock_load_configuration = patch('ansible.modules.network.junos.junos_config.load_configuration')
|
||||
self.load_configuration = self.mock_load_configuration.start()
|
||||
|
||||
self.mock_lock_configuration = patch('ansible.module_utils.junos.lock_configuration')
|
||||
self.mock_lock_configuration = patch('ansible.module_utils.network.junos.junos.lock_configuration')
|
||||
self.lock_configuration = self.mock_lock_configuration.start()
|
||||
|
||||
self.mock_unlock_configuration = patch('ansible.module_utils.junos.unlock_configuration')
|
||||
self.mock_unlock_configuration = patch('ansible.module_utils.network.junos.junos.unlock_configuration')
|
||||
self.unlock_configuration = self.mock_unlock_configuration.start()
|
||||
|
||||
self.mock_commit_configuration = patch('ansible.modules.network.junos.junos_config.commit_configuration')
|
||||
@@ -57,13 +57,13 @@ class TestJunosConfigModule(TestJunosModule):
|
||||
self.mock_conn = patch('ansible.module_utils.connection.Connection')
|
||||
self.conn = self.mock_conn.start()
|
||||
|
||||
self.mock_netconf = patch('ansible.module_utils.junos.NetconfConnection')
|
||||
self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection')
|
||||
self.netconf_conn = self.mock_netconf.start()
|
||||
|
||||
self.mock_exec_rpc = patch('ansible.modules.network.junos.junos_config.exec_rpc')
|
||||
self.exec_rpc = self.mock_exec_rpc.start()
|
||||
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.netconf.NetconfConnection')
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection')
|
||||
self.netconf_rpc = self.mock_netconf_rpc.start()
|
||||
|
||||
def tearDown(self):
|
||||
|
||||
@@ -52,16 +52,16 @@ class TestJunosCommandModule(TestJunosModule):
|
||||
self.mock_conn = patch('ansible.module_utils.connection.Connection')
|
||||
self.conn = self.mock_conn.start()
|
||||
|
||||
self.mock_netconf = patch('ansible.module_utils.junos.NetconfConnection')
|
||||
self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection')
|
||||
self.netconf_conn = self.mock_netconf.start()
|
||||
|
||||
self.mock_exec_rpc = patch('ansible.modules.network.junos.junos_facts.exec_rpc')
|
||||
self.exec_rpc = self.mock_exec_rpc.start()
|
||||
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.netconf.NetconfConnection')
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection')
|
||||
self.netconf_rpc = self.mock_netconf_rpc.start()
|
||||
|
||||
self.mock_get_capabilities = patch('ansible.module_utils.junos.get_capabilities')
|
||||
self.mock_get_capabilities = patch('ansible.module_utils.network.junos.junos.get_capabilities')
|
||||
self.get_capabilities = self.mock_get_capabilities.start()
|
||||
self.get_capabilities.return_value = {'network_api': 'netconf'}
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ class TestJunosCommandModule(TestJunosModule):
|
||||
def setUp(self):
|
||||
super(TestJunosCommandModule, self).setUp()
|
||||
|
||||
self.mock_lock_configuration = patch('ansible.module_utils.junos.lock_configuration')
|
||||
self.mock_lock_configuration = patch('ansible.module_utils.network.junos.junos.lock_configuration')
|
||||
self.lock_configuration = self.mock_lock_configuration.start()
|
||||
|
||||
self.mock_unlock_configuration = patch('ansible.module_utils.junos.unlock_configuration')
|
||||
self.mock_unlock_configuration = patch('ansible.module_utils.network.junos.junos.unlock_configuration')
|
||||
self.unlock_configuration = self.mock_unlock_configuration.start()
|
||||
|
||||
self.mock_commit_configuration = patch('ansible.modules.network.junos.junos_netconf.commit_configuration')
|
||||
@@ -44,13 +44,13 @@ class TestJunosCommandModule(TestJunosModule):
|
||||
self.mock_conn = patch('ansible.module_utils.connection.Connection')
|
||||
self.conn = self.mock_conn.start()
|
||||
|
||||
self.mock_netconf = patch('ansible.module_utils.junos.NetconfConnection')
|
||||
self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection')
|
||||
self.netconf_conn = self.mock_netconf.start()
|
||||
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.netconf.NetconfConnection')
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection')
|
||||
self.netconf_rpc = self.mock_netconf_rpc.start()
|
||||
|
||||
self.mock_get_capabilities = patch('ansible.module_utils.junos.get_capabilities')
|
||||
self.mock_get_capabilities = patch('ansible.module_utils.network.junos.junos.get_capabilities')
|
||||
self.get_capabilities = self.mock_get_capabilities.start()
|
||||
self.get_capabilities.return_value = {'network_api': 'netconf'}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ class TestJunosCommandModule(TestJunosModule):
|
||||
self.mock_conn = patch('ansible.module_utils.connection.Connection')
|
||||
self.conn = self.mock_conn.start()
|
||||
|
||||
self.mock_netconf = patch('ansible.module_utils.junos.NetconfConnection')
|
||||
self.mock_netconf = patch('ansible.module_utils.network.junos.junos.NetconfConnection')
|
||||
self.netconf_conn = self.mock_netconf.start()
|
||||
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.netconf.NetconfConnection')
|
||||
self.mock_netconf_rpc = patch('ansible.module_utils.network.common.netconf.NetconfConnection')
|
||||
self.netconf_rpc = self.mock_netconf_rpc.start()
|
||||
|
||||
self.mock_exec_rpc = patch('ansible.modules.network.junos.junos_rpc.exec_rpc')
|
||||
|
||||
@@ -21,7 +21,7 @@ from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import Mock
|
||||
|
||||
|
||||
from ansible.module_utils.netscaler import ConfigProxy, get_immutables_intersection, ensure_feature_is_enabled, log, loglines
|
||||
from ansible.module_utils.network.netscaler.netscaler import ConfigProxy, get_immutables_intersection, ensure_feature_is_enabled, log, loglines
|
||||
|
||||
|
||||
class TestNetscalerConfigProxy(unittest.TestCase):
|
||||
|
||||
@@ -30,11 +30,11 @@ from .nso_module import MockResponse
|
||||
class TestNsoConfig(nso_module.TestNsoModule):
|
||||
module = nso_config
|
||||
|
||||
@patch('ansible.module_utils.nso.open_url')
|
||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||
def test_nso_config_invalid_version_short(self, open_url_mock):
|
||||
self._test_invalid_version(open_url_mock, '4.4')
|
||||
|
||||
@patch('ansible.module_utils.nso.open_url')
|
||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||
def test_nso_config_invalid_version_long(self, open_url_mock):
|
||||
self._test_invalid_version(open_url_mock, '4.4.2')
|
||||
|
||||
@@ -56,11 +56,11 @@ class TestNsoConfig(nso_module.TestNsoModule):
|
||||
|
||||
self.assertEqual(0, len(calls))
|
||||
|
||||
@patch('ansible.module_utils.nso.open_url')
|
||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||
def test_nso_config_valid_version_short(self, open_url_mock):
|
||||
self._test_valid_version(open_url_mock, '4.5')
|
||||
|
||||
@patch('ansible.module_utils.nso.open_url')
|
||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||
def test_nso_config_valid_version_long(self, open_url_mock):
|
||||
self._test_valid_version(open_url_mock, '4.4.3')
|
||||
|
||||
@@ -84,7 +84,7 @@ class TestNsoConfig(nso_module.TestNsoModule):
|
||||
|
||||
self.assertEqual(0, len(calls))
|
||||
|
||||
@patch('ansible.module_utils.nso.open_url')
|
||||
@patch('ansible.module_utils.network.nso.nso.open_url')
|
||||
def test_nso_config_changed(self, open_url_mock):
|
||||
vpn_schema = nso_module.load_fixture('l3vpn_schema.json')
|
||||
l3vpn_schema = nso_module.load_fixture('l3vpn_l3vpn_schema.json')
|
||||
|
||||
Reference in New Issue
Block a user