Пример #1
0
    def setUp(self):
        super(TestDcnmServiceNodeModule, self).setUp()

        self.mock_dcnm_ip_sn = patch(
            'ansible_collections.cisco.dcnm.plugins.modules.dcnm_service_node.get_fabric_inventory_details'
        )
        self.run_dcnm_ip_sn = self.mock_dcnm_ip_sn.start()

        self.mock_dcnm_send = patch(
            'ansible_collections.cisco.dcnm.plugins.modules.dcnm_service_node.dcnm_send'
        )
        self.run_dcnm_send = self.mock_dcnm_send.start()
Пример #2
0
    def setUp(self):
        super(TestDcnmInvModule, self).setUp()

        self.mock_dcnm_send = patch(
            'ansible_collections.cisco.dcnm.plugins.modules.dcnm_inventory.dcnm_send'
        )
        self.run_dcnm_send = self.mock_dcnm_send.start()
    def setUp(self):
        super(TestCliConfigModule, self).setUp()

        self.mock_connection = patch(
            "ansible_collections.ansible.netcommon.plugins.modules.cli_config.Connection"
        )
        self.get_connection = self.mock_connection.start()

        self.conn = self.get_connection()
Пример #4
0
 def setUp(self):
     self.mock_module = patch.multiple(basic.AnsibleModule,
                                       exit_json=exit_json,
                                       fail_json=fail_json)
     self.mock_module.start()
     self.mock_sleep = patch("time.sleep")
     self.mock_sleep.start()
     set_module_args({})
     self.addCleanup(self.mock_module.stop)
     self.addCleanup(self.mock_sleep.stop)
Пример #5
0
    def setUp(self):

        super(TestDcnmTemplateModule, self).setUp()

        self.mock_dcnm_send = patch('ansible_collections.cisco.dcnm.plugins.modules.dcnm_template.dcnm_send')
        self.run_dcnm_send  = self.mock_dcnm_send.start()
Пример #6
0
PY3 = sys.version_info[0] == 3

builtin_import = __import__

mock_ncclient = MagicMock(name="ncclient")
mock_ncclient.__version__ = "0.6.10"


def import_mock(name, *args):
    if name.startswith("ncclient"):
        return mock_ncclient
    return builtin_import(name, *args)


if PY3:
    with patch("builtins.__import__", side_effect=import_mock):
        from ansible_collections.ansible.netcommon.plugins.connection import (
            netconf, )
        from ansible.plugins.loader import connection_loader
else:
    with patch("__builtin__.__import__", side_effect=import_mock):
        from ansible_collections.ansible.netcommon.plugins.connection import (
            netconf, )
        from ansible.plugins.loader import connection_loader


class TestNetconfConnectionClass(unittest.TestCase):
    def test_netconf_init(self):
        pc = PlayContext()
        conn = connection_loader.get("netconf", pc, "/dev/null")
Пример #7
0
PY3 = sys.version_info[0] == 3

builtin_import = __import__

mock_ncclient = MagicMock(name='ncclient')


def import_mock(name, *args):
    if name.startswith('ncclient'):
        return mock_ncclient
    return builtin_import(name, *args)


if PY3:
    with patch('builtins.__import__', side_effect=import_mock):
        from ansible_collections.ansible.netcommon.plugins.connection import netconf
        from ansible.plugins.loader import connection_loader
else:
    with patch('__builtin__.__import__', side_effect=import_mock):
        from ansible_collections.ansible.netcommon.plugins.connection import netconf
        from ansible.plugins.loader import connection_loader


class TestNetconfConnectionClass(unittest.TestCase):
    def test_netconf_connection_module(self):
        play_context = PlayContext()
        play_context.prompt = (
            '[sudo via ansible, key=ouzmdnewuhucvuaabtjmweasarviygqq] password: '
        )
        in_stream = StringIO()