From 02c5c059858b55cf1cbeeefabca01a439c4dac96 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Wed, 7 Dec 2022 11:10:06 -0800 Subject: [PATCH] Patch more boto sessions for certain scenarios --- tests/lib/hook_test.py | 8 ++++++-- tests/lib/resource_test.py | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/lib/hook_test.py b/tests/lib/hook_test.py index c8771fe..41ccd85 100644 --- a/tests/lib/hook_test.py +++ b/tests/lib/hook_test.py @@ -89,7 +89,9 @@ def test_entrypoint_success(): "cloudformation_cli_python_lib.hook.HookProviderLogHandler.setup" ) as mock_log_delivery, patch( "cloudformation_cli_python_lib.hook.KmsCipher.decrypt_credentials" - ) as mock_cipher: + ) as mock_cipher, patch( + "cloudformation_cli_python_lib.hook._get_boto_session", autospec=True + ): mock_cipher.side_effect = lambda c: Credentials(**json.loads(c)) event = hook.__call__.__wrapped__( # pylint: disable=no-member hook, ENTRYPOINT_PAYLOAD, None @@ -158,7 +160,9 @@ def test_entrypoint_with_context(): "cloudformation_cli_python_lib.hook.HookProviderLogHandler.setup" ), patch( "cloudformation_cli_python_lib.hook.KmsCipher.decrypt_credentials" - ) as mock_cipher: + ) as mock_cipher, patch( + "cloudformation_cli_python_lib.hook._get_boto_session", autospec=True + ): mock_cipher.side_effect = lambda c: Credentials(**json.loads(c)) hook.__call__.__wrapped__(hook, payload, None) # pylint: disable=no-member diff --git a/tests/lib/resource_test.py b/tests/lib/resource_test.py index e8234a2..fcb3638 100644 --- a/tests/lib/resource_test.py +++ b/tests/lib/resource_test.py @@ -84,7 +84,9 @@ def test_entrypoint_success(): with patch( "cloudformation_cli_python_lib.resource.ProviderLogHandler.setup" - ) as mock_log_delivery: + ) as mock_log_delivery, patch( + "cloudformation_cli_python_lib.hook._get_boto_session", autospec=True + ): event = resource.__call__.__wrapped__( # pylint: disable=no-member resource, ENTRYPOINT_PAYLOAD, None ) @@ -164,7 +166,9 @@ def test_entrypoint_with_context(): ) mock_handler = resource.handler(Action.CREATE)(Mock(return_value=event)) - with patch("cloudformation_cli_python_lib.resource.ProviderLogHandler.setup"): + with patch( + "cloudformation_cli_python_lib.resource.ProviderLogHandler.setup" + ), patch("cloudformation_cli_python_lib.hook._get_boto_session", autospec=True): resource.__call__.__wrapped__( # pylint: disable=no-member resource, payload, None ) @@ -181,7 +185,9 @@ def test_entrypoint_ignore_remove_fields_from_response(): with patch( "cloudformation_cli_python_lib.resource.ProviderLogHandler.setup" - ) as mock_log_delivery: + ) as mock_log_delivery, patch( + "cloudformation_cli_python_lib.hook._get_boto_session", autospec=True + ): event = resource.__call__.__wrapped__( # pylint: disable=no-member resource, ENTRYPOINT_PAYLOAD, None )