Skip to content

Commit ce819ea

Browse files
committed
Fix sanity tests
1 parent 50039cb commit ce819ea

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

plugins/plugin_utils/ssm_file_transfer.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Dict
1818
from typing import List
1919
from typing import NoReturn
20+
from typing import Optional
2021
from typing import Union
2122

2223
from ansible.errors import AnsibleConnectionFailure
@@ -27,7 +28,7 @@
2728

2829

2930
class ConnectionPluginDisplay:
30-
def __init__(self, host: str | None) -> None:
31+
def __init__(self, host: Optional[str]) -> None:
3132
self._host_args = {}
3233
if host:
3334
self._host_args = {"host": host}
@@ -111,10 +112,10 @@ def __init__(
111112
instance_id: str,
112113
executable: str,
113114
ssm_timeout: int,
114-
region_name: str | None,
115+
region_name: Optional[str],
115116
profile_name: str,
116-
document_name: str | None = None,
117-
parameters: Dict[str, List[str]] | None = None,
117+
document_name: Optional[str] = None,
118+
parameters: Optional[Dict[str, List[str]]] = None,
118119
) -> None:
119120
self._client = ssm_client
120121
self._session = None
@@ -178,15 +179,15 @@ class PortForwardingFileTransferManager:
178179

179180
def __init__(
180181
self,
181-
host: str | None,
182+
host: Optional[str],
182183
ssm_client: Any,
183184
instance_id: str,
184185
executable: str,
185186
ssm_timeout: int,
186-
region_name: str | None,
187+
region_name: Optional[str],
187188
profile_name: str,
188-
host_port: int | None = None,
189-
local_port: int | None = None,
189+
host_port: Optional[int],
190+
local_port: Optional[int],
190191
) -> None:
191192
self._client = ssm_client
192193
self._session = None
@@ -244,7 +245,7 @@ def _socket_connect(self, session: Any, port: int, host: str = "localhost", max_
244245
raise
245246
time.sleep(0.05)
246247

247-
def _socket_read(self, port: int, out_path: str | None = None) -> None:
248+
def _socket_read(self, port: int, out_path: Optional[str] = None) -> None:
248249
self._display.vvvv(f"Read content from socket on port '{port}'...")
249250
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as session:
250251
session.settimeout(1)

tests/unit/plugins/connection/aws_ssm/test_aws_ssm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def mock_get_option(key):
4343

4444
# Mock the _initialize_ssm_client and _initialize_s3_client methods
4545
conn._initialize_ssm_client = MagicMock()
46+
conn._use_bucket = MagicMock()
47+
conn._use_bucket.return_value = True
4648

4749
conn._init_clients()
4850

@@ -196,6 +198,8 @@ def test_plugins_connection_aws_ssm_put_file(self, mock_ospe):
196198
conn._connect = MagicMock()
197199
conn._file_transport_command = MagicMock()
198200
conn._file_transport_command.return_value = (0, "stdout", "stderr")
201+
conn._use_bucket = MagicMock()
202+
conn._use_bucket.return_value = True
199203
conn.put_file("/in/file", "/out/file")
200204

201205
def test_plugins_connection_aws_ssm_fetch_file(self):
@@ -205,6 +209,8 @@ def test_plugins_connection_aws_ssm_fetch_file(self):
205209
conn._connect = MagicMock()
206210
conn._file_transport_command = MagicMock()
207211
conn._file_transport_command.return_value = (0, "stdout", "stderr")
212+
conn._use_bucket = MagicMock()
213+
conn._use_bucket.return_value = True
208214
conn.fetch_file("/in/file", "/out/file")
209215

210216
@patch("subprocess.check_output")

0 commit comments

Comments
 (0)