-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connection/aws_ssm - refactor exec_command function to improve readab…
…ility fix linters create dedicated conftest.py for aws_ssm add conftest.py fix isort
- Loading branch information
Showing
5 changed files
with
322 additions
and
78 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelogs/fragments/20250130-aws_ssm-refactor-exec_command.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
minor_changes: | ||
- aws_ssm - Refactor exec_command Method for Improved Clarity and Efficiency (https://github.com/ansible-collections/community.aws/pull/2224). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
|
||
from ansible_collections.community.aws.plugins.connection.aws_ssm import Connection | ||
from ansible_collections.community.aws.plugins.connection.aws_ssm import ConnectionBase | ||
|
||
|
||
@pytest.fixture(name="connection_aws_ssm") | ||
def fixture_connection_aws_ssm(): | ||
play_context = MagicMock() | ||
play_context.shell = True | ||
|
||
def connection_init(*args, **kwargs): | ||
pass | ||
|
||
Connection.__init__ = connection_init | ||
ConnectionBase.exec_command = MagicMock() | ||
connection = Connection() | ||
|
||
connection._instance_id = "i-0a1b2c3d4e5f" | ||
connection._polling_obj = None | ||
connection._has_timeout = False | ||
connection.is_windows = False | ||
|
||
connection.poll_stdout = MagicMock() | ||
connection._session = MagicMock() | ||
connection._session.poll = MagicMock() | ||
connection._session.poll.side_effect = lambda: None | ||
connection._stdout = MagicMock() | ||
connection._flush_stderr = MagicMock() | ||
|
||
def display_msg(msg): | ||
print("--- AWS SSM CONNECTION --- ", msg) | ||
|
||
connection._v = MagicMock() | ||
connection._v.side_effect = display_msg | ||
|
||
connection._vv = MagicMock() | ||
connection._vv.side_effect = display_msg | ||
|
||
connection._vvv = MagicMock() | ||
connection._vvv.side_effect = display_msg | ||
|
||
connection._vvvv = MagicMock() | ||
connection._vvvv.side_effect = display_msg | ||
|
||
connection.get_option = MagicMock() | ||
return connection |
File renamed without changes.
Oops, something went wrong.