mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Base connection class for network-style connections (#41839)
* Create base class for network-style connections * clean up some differences * Move NetworkConnectionBase * Tweak netconf for tests * Tweak when network_os is checked to avoid failing tests * Pull back exec_command
This commit is contained in:
@@ -46,9 +46,11 @@ def import_mock(name, *args):
|
||||
if PY3:
|
||||
with patch('builtins.__import__', side_effect=import_mock):
|
||||
from ansible.plugins.connection import netconf
|
||||
from ansible.plugins.loader import connection_loader
|
||||
else:
|
||||
with patch('__builtin__.__import__', side_effect=import_mock):
|
||||
from ansible.plugins.connection import netconf
|
||||
from ansible.plugins.loader import connection_loader
|
||||
|
||||
|
||||
class TestNetconfConnectionClass(unittest.TestCase):
|
||||
@@ -68,7 +70,7 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
conn = connection_loader.get('netconf', pc, new_stdin)
|
||||
|
||||
mock_manager = MagicMock()
|
||||
mock_manager.session_id = '123456789'
|
||||
|
||||
@@ -64,10 +64,10 @@ class TestConnectionClass(unittest.TestCase):
|
||||
@patch("ansible.plugins.connection.paramiko_ssh.Connection._connect")
|
||||
def test_network_cli__connect(self, mocked_super, mocked_terminal_loader):
|
||||
pc = PlayContext()
|
||||
pc.network_os = 'ios'
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = connection_loader.get('network_cli', pc, '/dev/null')
|
||||
pc.network_os = 'ios'
|
||||
|
||||
conn.ssh = MagicMock()
|
||||
conn.receive = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user