Skip to content

Commit 1e0b1a9

Browse files
authored
Patch more boto sessions for certain scenarios (#234)
1 parent fad3b07 commit 1e0b1a9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

tests/lib/hook_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def test_entrypoint_success():
8989
"cloudformation_cli_python_lib.hook.HookProviderLogHandler.setup"
9090
) as mock_log_delivery, patch(
9191
"cloudformation_cli_python_lib.hook.KmsCipher.decrypt_credentials"
92-
) as mock_cipher:
92+
) as mock_cipher, patch(
93+
"cloudformation_cli_python_lib.hook._get_boto_session", autospec=True
94+
):
9395
mock_cipher.side_effect = lambda c: Credentials(**json.loads(c))
9496
event = hook.__call__.__wrapped__( # pylint: disable=no-member
9597
hook, ENTRYPOINT_PAYLOAD, None
@@ -158,7 +160,9 @@ def test_entrypoint_with_context():
158160
"cloudformation_cli_python_lib.hook.HookProviderLogHandler.setup"
159161
), patch(
160162
"cloudformation_cli_python_lib.hook.KmsCipher.decrypt_credentials"
161-
) as mock_cipher:
163+
) as mock_cipher, patch(
164+
"cloudformation_cli_python_lib.hook._get_boto_session", autospec=True
165+
):
162166
mock_cipher.side_effect = lambda c: Credentials(**json.loads(c))
163167
hook.__call__.__wrapped__(hook, payload, None) # pylint: disable=no-member
164168

tests/lib/resource_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ def test_entrypoint_success():
8484

8585
with patch(
8686
"cloudformation_cli_python_lib.resource.ProviderLogHandler.setup"
87-
) as mock_log_delivery:
87+
) as mock_log_delivery, patch(
88+
"cloudformation_cli_python_lib.hook._get_boto_session", autospec=True
89+
):
8890
event = resource.__call__.__wrapped__( # pylint: disable=no-member
8991
resource, ENTRYPOINT_PAYLOAD, None
9092
)
@@ -164,7 +166,9 @@ def test_entrypoint_with_context():
164166
)
165167
mock_handler = resource.handler(Action.CREATE)(Mock(return_value=event))
166168

167-
with patch("cloudformation_cli_python_lib.resource.ProviderLogHandler.setup"):
169+
with patch(
170+
"cloudformation_cli_python_lib.resource.ProviderLogHandler.setup"
171+
), patch("cloudformation_cli_python_lib.hook._get_boto_session", autospec=True):
168172
resource.__call__.__wrapped__( # pylint: disable=no-member
169173
resource, payload, None
170174
)
@@ -181,7 +185,9 @@ def test_entrypoint_ignore_remove_fields_from_response():
181185

182186
with patch(
183187
"cloudformation_cli_python_lib.resource.ProviderLogHandler.setup"
184-
) as mock_log_delivery:
188+
) as mock_log_delivery, patch(
189+
"cloudformation_cli_python_lib.hook._get_boto_session", autospec=True
190+
):
185191
event = resource.__call__.__wrapped__( # pylint: disable=no-member
186192
resource, ENTRYPOINT_PAYLOAD, None
187193
)

0 commit comments

Comments
 (0)