update paramiko_ssh unit tests load the connection with plugin loader (#80157)

* Load the paramiko_ssh connection plugin properly using plugin loader so it can use config manager when _connect() is called
pull/80158/head
Sloane Hertel 2 years ago committed by GitHub
parent a1bff416ed
commit 9a03c8f5b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,8 @@ __metaclass__ = type
from io import StringIO from io import StringIO
import pytest import pytest
from ansible.plugins.connection import paramiko_ssh from ansible.plugins.connection import paramiko_ssh as paramiko_ssh_module
from ansible.plugins.loader import connection_loader
from ansible.playbook.play_context import PlayContext from ansible.playbook.play_context import PlayContext
@ -44,13 +45,14 @@ def in_stream():
def test_paramiko_connection_module(play_context, in_stream): def test_paramiko_connection_module(play_context, in_stream):
assert isinstance( assert isinstance(
paramiko_ssh.Connection(play_context, in_stream), connection_loader.get('paramiko_ssh', play_context, in_stream),
paramiko_ssh.Connection) paramiko_ssh_module.Connection)
def test_paramiko_connect(play_context, in_stream, mocker): def test_paramiko_connect(play_context, in_stream, mocker):
mocker.patch.object(paramiko_ssh.Connection, '_connect_uncached') paramiko_ssh = connection_loader.get('paramiko_ssh', play_context, in_stream)
connection = paramiko_ssh.Connection(play_context, in_stream)._connect() mocker.patch.object(paramiko_ssh, '_connect_uncached')
connection = paramiko_ssh._connect()
assert isinstance(connection, paramiko_ssh.Connection) assert isinstance(connection, paramiko_ssh_module.Connection)
assert connection._connected is True assert connection._connected is True

Loading…
Cancel
Save