mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-07 17:51:29 -07:00
Move persistent connections to only use registered variables (#45616)
* Try to intuit proper plugins to send to ansible-connection * Move sub-plugins to init so that vars will be populated in executor * Fix connection unit tests
This commit is contained in:
parent
86c48205c4
commit
406b59aeba
10 changed files with 98 additions and 109 deletions
|
@ -58,9 +58,7 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
|||
|
||||
def test_netconf_init(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
conn = connection_loader.get('netconf', pc, '/dev/null')
|
||||
|
||||
self.assertEqual('default', conn._network_os)
|
||||
self.assertIsNone(conn._manager)
|
||||
|
@ -69,14 +67,11 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
|||
@patch("ansible.plugins.connection.netconf.netconf_loader")
|
||||
def test_netconf__connect(self, mock_netconf_loader):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
|
||||
conn = connection_loader.get('netconf', pc, new_stdin)
|
||||
conn = connection_loader.get('netconf', pc, '/dev/null')
|
||||
|
||||
mock_manager = MagicMock()
|
||||
mock_manager.session_id = '123456789'
|
||||
netconf.manager.connect = MagicMock(return_value=mock_manager)
|
||||
conn._play_context.network_os = 'default'
|
||||
|
||||
rc, out, err = conn._connect()
|
||||
|
||||
|
@ -87,9 +82,8 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
|||
|
||||
def test_netconf_exec_command(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = connection_loader.get('netconf', pc, '/dev/null')
|
||||
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
conn._connected = True
|
||||
|
||||
mock_reply = MagicMock(name='reply')
|
||||
|
@ -105,9 +99,8 @@ class TestNetconfConnectionClass(unittest.TestCase):
|
|||
|
||||
def test_netconf_exec_command_invalid_request(self):
|
||||
pc = PlayContext()
|
||||
new_stdin = StringIO()
|
||||
conn = connection_loader.get('netconf', pc, '/dev/null')
|
||||
|
||||
conn = netconf.Connection(pc, new_stdin)
|
||||
conn._connected = True
|
||||
|
||||
mock_manager = MagicMock(name='self._manager')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue