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:
Nathaniel Case 2018-09-20 09:56:43 -04:00 committed by GitHub
parent 86c48205c4
commit 406b59aeba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 98 additions and 109 deletions

View file

@ -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')